Fix unchecked malloc in papi_result_async (#307)

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

Co-authored-by: Levi Neely <lkn@darkstar.example.net>
This commit is contained in:
Levi Neely 2026-03-03 12:41:27 +01:00 committed by GitHub
parent 87ab65b68c
commit fb8d0fc608
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
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);