[PATCH 12/16] om: Fix potential memory leak in init_om.
Ander Conselvan de Oliveira
ander.conselvan-de-oliveira at nokia.com
Wed Mar 30 06:12:05 PDT 2011
Signed-off-by: Ander Conselvan de Oliveira <ander.conselvan-de-oliveira at nokia.com>
---
modules/om/generic/omGeneric.c | 22 ++++++++++++----------
1 files changed, 12 insertions(+), 10 deletions(-)
diff --git a/modules/om/generic/omGeneric.c b/modules/om/generic/omGeneric.c
index ec2abc0..6088350 100644
--- a/modules/om/generic/omGeneric.c
+++ b/modules/om/generic/omGeneric.c
@@ -2121,22 +2121,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 */
--
1.7.0.4
More information about the xorg-devel
mailing list