aboutsummaryrefslogtreecommitdiff
path: root/nx-X11/lib/X11
diff options
context:
space:
mode:
authorAnder Conselvan de Oliveira <ander.conselvan-de-oliveira@nokia.com>2011-03-25 16:06:15 +0200
committerUlrich Sibiller <uli42@gmx.de>2016-10-19 21:40:25 +0200
commit748cf8946537e0c199cbf2f19cdc582001ea8232 (patch)
treeee70d5cd826e85c1ea40deb3bfd0883b2382d425 /nx-X11/lib/X11
parent6fe8d44ca01c56b5d639c258ad73a5d0b74fc6b8 (diff)
downloadnx-libs-748cf8946537e0c199cbf2f19cdc582001ea8232.tar.gz
nx-libs-748cf8946537e0c199cbf2f19cdc582001ea8232.tar.bz2
nx-libs-748cf8946537e0c199cbf2f19cdc582001ea8232.zip
om: Fix potential memory leak in init_om.
Signed-off-by: Ander Conselvan de Oliveira <ander.conselvan-de-oliveira@nokia.com> Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com> Backported-to-NX-by: Ulrich Sibiller <uli42@gmx.de>
Diffstat (limited to 'nx-X11/lib/X11')
-rw-r--r--nx-X11/lib/X11/omGeneric.c22
1 files changed, 12 insertions, 10 deletions
diff --git a/nx-X11/lib/X11/omGeneric.c b/nx-X11/lib/X11/omGeneric.c
index e54b27c29..dbddc8415 100644
--- a/nx-X11/lib/X11/omGeneric.c
+++ b/nx-X11/lib/X11/omGeneric.c
@@ -2094,22 +2094,24 @@ init_om(
if (required_list == NULL)
return False;
- bufptr = (char *) Xmalloc(length);
- if (bufptr == NULL) {
- Xfree(required_list);
- return False;
- }
-
om->core.required_charset.charset_list = required_list;
om->core.required_charset.charset_count = gen->data_num;
count = gen->data_num;
data = gen->data;
- for ( ; count-- > 0; data++) {
- strcpy(bufptr, data->font_data->name);
- *required_list++ = bufptr;
- bufptr += strlen(bufptr) + 1;
+ if (count > 0) {
+ bufptr = (char *) Xmalloc(length);
+ if (bufptr == NULL) {
+ Xfree(required_list);
+ return False;
+ }
+
+ for ( ; count-- > 0; data++) {
+ strcpy(bufptr, data->font_data->name);
+ *required_list++ = bufptr;
+ bufptr += strlen(bufptr) + 1;
+ }
}
/* orientation list */