summaryrefslogtreecommitdiff
path: root/src/gd_topal.c
diff options
context:
space:
mode:
authorKornel Lesiński <kornel@geekhood.net>2013-03-09 13:06:16 +0000
committerKornel Lesiński <kornel@geekhood.net>2013-03-09 13:06:16 +0000
commit4b20813579ee07cb3a6a9e7756b7ecd3ec317007 (patch)
treeca9d6df39abc5a2748847a038b236847208adc9d /src/gd_topal.c
parent1d9a609b5fe57a531f14b49dc44ffa176c40b9c0 (diff)
downloadlibgd-4b20813579ee07cb3a6a9e7756b7ecd3ec317007.tar.gz
Avoid NULL pointer dereference by checking if parent struct has been allocated first
--HG-- extra : rebase_source : 2755ec5ce2de7dc7046dc13e3f77a880222290f9
Diffstat (limited to 'src/gd_topal.c')
-rw-r--r--src/gd_topal.c40
1 files changed, 20 insertions, 20 deletions
diff --git a/src/gd_topal.c b/src/gd_topal.c
index 48fd632..097c578 100644
--- a/src/gd_topal.c
+++ b/src/gd_topal.c
@@ -1661,30 +1661,30 @@ outOfMemory:
}
}
success:
- for (i = 0; i < HIST_C0_ELEMS; i++)
- {
- if (cquantize->histogram[i])
- {
- gdFree (cquantize->histogram[i]);
- }
- }
- if (cquantize->histogram)
- {
- gdFree (cquantize->histogram);
- }
- if (cquantize->fserrors)
- {
- gdFree (cquantize->fserrors);
- }
- if (cquantize->error_limiter_storage)
- {
- gdFree (cquantize->error_limiter_storage);
- }
+
if (cquantize)
{
+ if (cquantize->histogram)
+ {
+ for (i = 0; i < HIST_C0_ELEMS; i++)
+ {
+ if (cquantize->histogram[i])
+ {
+ gdFree (cquantize->histogram[i]);
+ }
+ }
+ gdFree (cquantize->histogram);
+ }
+ if (cquantize->fserrors)
+ {
+ gdFree (cquantize->fserrors);
+ }
+ if (cquantize->error_limiter_storage)
+ {
+ gdFree (cquantize->error_limiter_storage);
+ }
gdFree (cquantize);
}
-
}
#endif