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
This commit is contained in:
Levi Neely 2026-03-03 12:37:55 +01:00
parent 87ab65b68c
commit 1e053e2c7e
1 changed files with 5 additions and 0 deletions

View File

@ -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);