summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNathan Kinder <nkinder@redhat.com>2010-09-14 14:53:43 -0700
committerNathan Kinder <nkinder@redhat.com>2010-09-15 09:11:06 -0700
commit50df94f549ae75669c071e610d08ffa9ed9e841c (patch)
tree0b70dcd5ba043cc323c60941c1cd03080c1b109c
parentb95332620490521a66b248e7e3840507f86705a9 (diff)
downloadds-50df94f549ae75669c071e610d08ffa9ed9e841c.tar.gz
ds-50df94f549ae75669c071e610d08ffa9ed9e841c.tar.xz
ds-50df94f549ae75669c071e610d08ffa9ed9e841c.zip
Bug 630097 - (cov#15473) NULL dereference in ResHashCreate()
If there is a problem allocating pResHash, we jump to the error label. The error label then dereferences pResHash to do a deep free, but it doesn't check if pResHash is NULL first. We need to check if pResHash is NULL before dereferencing it.
-rw-r--r--lib/libsi18n/reshash.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/lib/libsi18n/reshash.c b/lib/libsi18n/reshash.c
index 4134b2f9..6e3572fa 100644
--- a/lib/libsi18n/reshash.c
+++ b/lib/libsi18n/reshash.c
@@ -276,8 +276,8 @@ ResHash * ResHashCreate(char * name)
goto done;
error:
- if (pResHash->treelist && pResHash->treelist->vlist) free(pResHash->treelist->vlist);
- if (pResHash->treelist) free(pResHash->treelist);
+ if (pResHash && pResHash->treelist && pResHash->treelist->vlist) free(pResHash->treelist->vlist);
+ if (pResHash && pResHash->treelist) free(pResHash->treelist);
if (pResHash) free(pResHash);
return NULL;