summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorGravatar Martin Szulecki2013-11-20 16:57:21 +0100
committerGravatar Martin Szulecki2013-11-20 17:04:04 +0100
commit66c0deefae3295af4b740eea0fe4fc604929dadf (patch)
tree7acb684738efae1c85556aea7ccca516cdb736e9 /src
parent7198779b62231307f572fb4fdeb184c1a95e62d4 (diff)
downloadidevicerestore-66c0deefae3295af4b740eea0fe4fc604929dadf.tar.gz
idevicerestore-66c0deefae3295af4b740eea0fe4fc604929dadf.tar.bz2
img4: Make sure to free created element headers to fix memory leak
Diffstat (limited to 'src')
-rw-r--r--src/img4.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/img4.c b/src/img4.c
index ebe2ccd..17a4664 100644
--- a/src/img4.c
+++ b/src/img4.c
@@ -117,6 +117,15 @@ int img4_stitch_component(const char* component_name, const unsigned char* compo
outbuf = (unsigned char*)malloc(img4header_size + content_size);
if (!outbuf) {
+ if (magic_header) {
+ free(magic_header);
+ }
+ if (blob_header) {
+ free(blob_header);
+ }
+ if (img4header) {
+ free(img4header);
+ }
return -1;
}
p = outbuf;
@@ -138,5 +147,15 @@ int img4_stitch_component(const char* component_name, const unsigned char* compo
*img4_data = outbuf;
*img4_size = (p - outbuf);
+ if (magic_header) {
+ free(magic_header);
+ }
+ if (blob_header) {
+ free(blob_header);
+ }
+ if (img4header) {
+ free(img4header);
+ }
+
return 0;
}