aboutsummaryrefslogtreecommitdiff
path: root/nx-X11/programs/Xserver
diff options
context:
space:
mode:
authorAlan Coopersmith <alan.coopersmith@oracle.com>2012-07-14 11:21:15 -0700
committerUlrich Sibiller <uli42@gmx.de>2015-06-07 00:09:02 +0200
commit0fc419314b3bbafa873207dafa57ce92b4b9e1e1 (patch)
tree23544295c9991d13a76e598db5c4fe2cb80c8190 /nx-X11/programs/Xserver
parentfaddfbec6ff331c3859e2f57040da4a8cf072baa (diff)
downloadnx-libs-0fc419314b3bbafa873207dafa57ce92b4b9e1e1.tar.gz
nx-libs-0fc419314b3bbafa873207dafa57ce92b4b9e1e1.tar.bz2
nx-libs-0fc419314b3bbafa873207dafa57ce92b4b9e1e1.zip
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: Alan Coopersmith <alan.coopersmith@oracle.com> Reviewed-by: Keith Packard <keithp@keithp.com>
Diffstat (limited to 'nx-X11/programs/Xserver')
-rw-r--r--nx-X11/programs/Xserver/randr/rrmode.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/nx-X11/programs/Xserver/randr/rrmode.c b/nx-X11/programs/Xserver/randr/rrmode.c
index 09c011350..43ffe0705 100644
--- a/nx-X11/programs/Xserver/randr/rrmode.c
+++ b/nx-X11/programs/Xserver/randr/rrmode.c
@@ -98,8 +98,10 @@ RRModeCreate (xRRModeInfo *modeInfo,
}
mode->mode.id = FakeClientID(0);
- if (!AddResource (mode->mode.id, RRModeType, (pointer) mode))
- return NULL;
+ if (!AddResource(mode->mode.id, RRModeType, (pointer) mode)) {
+ free(newModes);
+ return NULL;
+ }
modes = newModes;
modes[num_modes++] = mode;