(1823) record: protect from memory allocation failure

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
This commit is contained in:
Enrico Weigelt, metux IT consult 2025-02-24 14:22:46 +01:00
parent 162cb6e18d
commit bd9df5b62c

View File

@ -2712,7 +2712,8 @@ RecordAClientStateChange(CallbackListPtr *pcbl, void *nulldata,
/* RecordDisableContext modifies contents of ppAllContexts. */ /* RecordDisableContext modifies contents of ppAllContexts. */
if (!(numContextsCopy = numContexts)) if (!(numContextsCopy = numContexts))
break; break;
ppAllContextsCopy = calloc(numContextsCopy, sizeof(RecordContextPtr)); if (!(ppAllContextsCopy = calloc(numContextsCopy, sizeof(RecordContextPtr))))
return;
assert(ppAllContextsCopy); assert(ppAllContextsCopy);
memcpy(ppAllContextsCopy, ppAllContexts, memcpy(ppAllContextsCopy, ppAllContexts,
numContextsCopy * sizeof(RecordContextPtr)); numContextsCopy * sizeof(RecordContextPtr));