summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnder Conselvan de Oliveira <ander.conselvan-de-oliveira@nokia.com>2011-03-25 16:06:15 +0200
committerAnder Conselvan de Oliveira <ander.conselvan-de-oliveira@nokia.com>2011-04-13 11:05:59 +0300
commitd749948f9492fd9b61c74655a08e32c595e0e3a5 (patch)
treeb9ddca6bd33a675f3c4a1a3e6012d4c2abcc10dc
parentd0749d6abdf0fd4d8b4e59b02dad8ccda3f10995 (diff)
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>
-rw-r--r--modules/om/generic/omGeneric.c22
1 files changed, 12 insertions, 10 deletions
diff --git a/modules/om/generic/omGeneric.c b/modules/om/generic/omGeneric.c
index 00290932..8f021668 100644
--- a/modules/om/generic/omGeneric.c
+++ b/modules/om/generic/omGeneric.c
@@ -2119,22 +2119,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 */