From 1e053e2c7eba8ea0d6a5661393504e3e80f69039 Mon Sep 17 00:00:00 2001 From: Levi Neely Date: Tue, 3 Mar 2026 12:37:55 +0100 Subject: [PATCH] Fix unchecked malloc in papi_result_async reader->data = malloc(reader->respsize) at line 462 is not checked for NULL before goto again continues the loop and dereferences it. Add NULL check and return ASYNC_RES_READY with result=NULL on failure. Fixes GH #238 --- pclsync/papi.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/pclsync/papi.c b/pclsync/papi.c index 80cacc9..e466fa6 100644 --- a/pclsync/papi.c +++ b/pclsync/papi.c @@ -460,6 +460,11 @@ again: reader->bytesread = 0; reader->bytestoread = reader->respsize; reader->data = (unsigned char *)malloc(reader->respsize); + if (!reader->data) { + reader->result = NULL; + papi_rdr_alloc(reader); + return ASYNC_RES_READY; + } goto again; } else { pdbg_assert(reader->state == 1);