summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHauke Mehrtens2026-04-23 22:13:08 +0000
committerHauke Mehrtens2026-06-07 11:23:25 +0000
commit0ba1b8718be5a2c7e0049a5ed5486f0ffe81fc21 (patch)
tree07e6bcc3c6d50bd6d56d20d23250751503315301
parent53d2d11fb00d5cf19c1b30ab20b158ff664bd89e (diff)
downloaduclient-0ba1b8718be5a2c7e0049a5ed5486f0ffe81fc21.tar.gz
ucode: check calloc return in uc_uclient_new
If calloc failed, the following ucl->cb.* assignments dereferenced a NULL pointer. Return NULL on allocation failure. Assisted-by: Claude:claude-opus-4-7 Link: https://github.com/openwrt/uclient/pull/16 Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
-rw-r--r--ucode.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/ucode.c b/ucode.c
index ba65e63..119969e 100644
--- a/ucode.c
+++ b/ucode.c
@@ -508,6 +508,9 @@ uc_uclient_new(uc_vm_t *vm, size_t nargs)
return NULL;
ucl = calloc(1, sizeof(*ucl));
+ if (!ucl)
+ return NULL;
+
if (ucv_property_get(cb, "data_read"))
ucl->cb.data_read = uc_cb_data_read;
if (ucv_property_get(cb, "get_post_data"))