Commit 954606d992 for ffmpeg
commit 954606d99215abb5114409d9aa27c16128ca0a2f
Author: Alex Vasilenko <olekv@google.com>
Date: Fri Oct 23 02:02:02 2026 +0000
avutil/tests/encryption_info: make compare_encryption_init_info iterative
Follow-up to 969c7eb09198, which replaced recursion with iteration in
av_encryption_init_info_free() to avoid stack exhaustion on long init
info lists. Replace the recursive call in compare_encryption_init_info()
with an iterative loop as well so tests can compare deep lists without
overflowing the stack.
Signed-off-by: Marvin Scholz <epirat07@gmail.com>
diff --git a/libavutil/tests/encryption_info.c b/libavutil/tests/encryption_info.c
index d8f0187ef9..84287a203a 100644
--- a/libavutil/tests/encryption_info.c
+++ b/libavutil/tests/encryption_info.c
@@ -47,28 +47,29 @@ static int compare_encryption_info(const AVEncryptionInfo *a, const AVEncryption
}
static int compare_encryption_init_info(const AVEncryptionInitInfo *a, const AVEncryptionInitInfo *b) {
- if (!a || !b || a->system_id_size != b->system_id_size ||
- a->num_key_ids != b->num_key_ids || a->key_id_size != b->key_id_size ||
- a->data_size != b->data_size)
+ if (!a || !b)
return 1;
- if (memcmp(a->system_id, b->system_id, a->system_id_size) != 0 ||
- memcmp(a->data, b->data, a->data_size) != 0)
- return 1;
-
- for (uint32_t i = 0; i < a->num_key_ids; i++) {
- if (memcmp(a->key_ids[i], b->key_ids[i], a->key_id_size) != 0)
+ while (a && b) {
+ if (a->system_id_size != b->system_id_size ||
+ a->num_key_ids != b->num_key_ids || a->key_id_size != b->key_id_size ||
+ a->data_size != b->data_size)
return 1;
- }
- if (a->next || b->next) {
- if (!a->next || !b->next)
- return 1;
- if (compare_encryption_init_info(a->next, b->next) != 0)
+ if (memcmp(a->system_id, b->system_id, a->system_id_size) != 0 ||
+ memcmp(a->data, b->data, a->data_size) != 0)
return 1;
+
+ for (uint32_t i = 0; i < a->num_key_ids; i++) {
+ if (memcmp(a->key_ids[i], b->key_ids[i], a->key_id_size) != 0)
+ return 1;
+ }
+
+ a = a->next;
+ b = b->next;
}
- return 0;
+ return a != b;
}
static void run_encryption_info_test(void)