Commit 0fc41931 authored by Alan Coopersmith's avatar Alan Coopersmith Committed by Ulrich Sibiller

Backport: RRModeCreate: plug memory leak of newModes if AddResource fails

Reported by parfait 1.0: Error: Memory leak (CWE 401) Memory leak of pointer 'newModes' allocated with realloc(((char*)modes), ((num_modes + 1) * 8)) at line 93 of randr/rrmode.c in function 'RRModeCreate'. pointer allocated at line 82 with realloc(((char*)modes), ((num_modes + 1) * 8)). Error: Memory leak (CWE 401) Memory leak of pointer 'newModes' allocated with malloc(8) at line 93 of randr/rrmode.c in function 'RRModeCreate'. pointer allocated at line 84 with malloc(8). Signed-off-by: 's avatarAlan Coopersmith <alan.coopersmith@oracle.com> Reviewed-by: 's avatarKeith Packard <keithp@keithp.com>
parent faddfbec
...@@ -98,8 +98,10 @@ RRModeCreate (xRRModeInfo *modeInfo, ...@@ -98,8 +98,10 @@ RRModeCreate (xRRModeInfo *modeInfo,
} }
mode->mode.id = FakeClientID(0); mode->mode.id = FakeClientID(0);
if (!AddResource (mode->mode.id, RRModeType, (pointer) mode)) if (!AddResource(mode->mode.id, RRModeType, (pointer) mode)) {
return NULL; free(newModes);
return NULL;
}
modes = newModes; modes = newModes;
modes[num_modes++] = mode; modes[num_modes++] = mode;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment