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 committed by Enrico Weigelt, metux IT consult .
parent 85eefbf721
commit 2263e514c4

View File

@ -2689,7 +2689,6 @@ RecordAClientStateChange(CallbackListPtr *pcbl, void *nulldata,
NewClientInfoRec *pci = (NewClientInfoRec *) calldata;
int i;
ClientPtr pClient = pci->client;
RecordContextPtr *ppAllContextsCopy = NULL;
int numContextsCopy = 0;
switch (pClient->clientState) {
@ -2714,8 +2713,9 @@ RecordAClientStateChange(CallbackListPtr *pcbl, void *nulldata,
/* RecordDisableContext modifies contents of ppAllContexts. */
if (!(numContextsCopy = numContexts))
break;
ppAllContextsCopy = calloc(numContextsCopy, sizeof(RecordContextPtr));
assert(ppAllContextsCopy);
RecordContextPtr *ppAllContextsCopy = calloc(numContextsCopy, sizeof(RecordContextPtr));
if (!ppAllContextsCopy)
return;
memcpy(ppAllContextsCopy, ppAllContexts,
numContextsCopy * sizeof(RecordContextPtr));