summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAlan Coopersmith <alan.coopersmith@oracle.com>2013-08-10 11:07:47 -0700
committerAlan Coopersmith <alan.coopersmith@oracle.com>2013-08-20 12:50:54 -0700
commit43bb822c714a73c3b2d15e621ffb3333cd10da8c (patch)
tree3148cab9b414da3e070ec40ccc2ef9f38b323a4d /src
parent5d47a39978e92bb34ec928b1b15d71c0c2434870 (diff)
Avoid memory leak/corruption if realloc fails in XlcDL.c:resolve_object()
Previously, if realloc failed to increase the size, we'd still record that we had allocated the larger size, but the pointer to it would be NULL, causing future calls to be broken, and the previous allocation to be lost/leaked. Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com> Reviewed-by: Matthieu Herrb <matthieu.herrb@laas.fr>
Diffstat (limited to 'src')
-rw-r--r--src/xlibi18n/XlcDL.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/src/xlibi18n/XlcDL.c b/src/xlibi18n/XlcDL.c
index 02860a02..2bef4ac1 100644
--- a/src/xlibi18n/XlcDL.c
+++ b/src/xlibi18n/XlcDL.c
@@ -207,12 +207,13 @@ resolve_object(char *path, const char *lc_name)
}
if (lc_count == lc_len) {
- lc_len += OBJECT_INC_LEN;
- xi18n_objects_list = (XI18NObjectsList)
- Xrealloc(xi18n_objects_list,
- sizeof(XI18NObjectsListRec) * lc_len);
- if (!xi18n_objects_list)
+ int new_len = lc_len + OBJECT_INC_LEN;
+ XI18NObjectsListRec *tmp = Xrealloc(xi18n_objects_list,
+ sizeof(XI18NObjectsListRec) * new_len);
+ if (tmp == NULL)
goto done;
+ xi18n_objects_list = tmp;
+ lc_len = new_len;
}
n = parse_line(p, args, 6);