diff options
| author | Hauke Mehrtens | 2026-04-08 22:15:02 +0000 |
|---|---|---|
| committer | Hauke Mehrtens | 2026-06-18 22:06:40 +0000 |
| commit | da9183de3707f3bf9a11d36d1ed3a26c1044d902 (patch) | |
| tree | 937861f2883c000228111698b29f70597bda163d | |
| parent | 8a28fbfab1b037b5f5a46e2fc37f551bf1eb6880 (diff) | |
| download | libubox-da9183de3707f3bf9a11d36d1ed3a26c1044d902.tar.gz | |
json_script: convert recursive __json_script_file_free() to iterative
The recursive implementation could overflow the stack with deeply
chained file lists. Use an iterative loop instead.
Link: https://github.com/openwrt/libubox/pull/42
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
(cherry picked from commit 78c20f6c8579c98a992c0a378850edeb5a63aace)
| -rw-r--r-- | json_script.c | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/json_script.c b/json_script.c index 7177e9c..ddcb3d1 100644 --- a/json_script.c +++ b/json_script.c @@ -639,13 +639,11 @@ static void __json_script_file_free(struct json_script_file *f) { struct json_script_file *next; - if (!f) - return; - - next = f->next; - free(f); - - __json_script_file_free(next); + while (f) { + next = f->next; + free(f); + f = next; + } } void |