summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorErkki Seppälä <erkki.seppala@vincit.fi>2011-01-31 14:02:05 +0200
committerAlan Coopersmith <alan.coopersmith@oracle.com>2011-02-01 23:46:06 -0800
commit3fae16c64d6ef76fd4a25a54c7f7de76596457db (patch)
tree53b183a465437b495cf44da632e5e35617cb42b3
parent7110ac653349a23c80c365f11f6270dc27c8975a (diff)
Xrm: NEWTABLE had a memory leak after a memory allocation error
The NEWTABLE macro missed freeing its allocated memory on subsequent memory allocation errors. Added call to Xfree. Variable "table" goes out of scope Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com> Reviewed-by: Ander Conselvan de Oliveira <ander.conselvan-de-oliveira@nokia.com> Signed-off-by: Erkki Seppälä <erkki.seppala@vincit.fi> Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
-rw-r--r--src/Xrm.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/Xrm.c b/src/Xrm.c
index 21f0af3..3e68c37 100644
--- a/src/Xrm.c
+++ b/src/Xrm.c
@@ -842,8 +842,10 @@ static void PutEntry(
nprev = NodeBuckets(table); \
} else { \
table->leaf = 1; \
- if (!(nprev = (NTable *)Xmalloc(sizeof(VEntry *)))) \
+ if (!(nprev = (NTable *)Xmalloc(sizeof(VEntry *)))) {\
+ Xfree(table); \
return; \
+ } \
((LTable)table)->buckets = (VEntry *)nprev; \
} \
*nprev = (NTable)NULL; \