summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMikhail Lappo2017-03-23 16:17:27 -0500
committerMikhail Lappo2017-03-23 16:41:14 -0500
commit26464914feccfce4b835bd73a1130ba5be069e8a (patch)
treeb597796b46dbc7e9aafd8e6295f2ae8f2e58f1f4
parentc0ca39c41ae2255ba86517ebe11c72b1fc44700d (diff)
downloadplatform-system-core-26464914feccfce4b835bd73a1130ba5be069e8a.tar.gz
platform-system-core-26464914feccfce4b835bd73a1130ba5be069e8a.tar.xz
platform-system-core-26464914feccfce4b835bd73a1130ba5be069e8a.zip
Possible null pointer miss on realloc
Realloc can return null pointer which will cause a crash then. Patch introduces check for controlled 'die' in case memory is not available Change-Id: I279028339b1fe756d8a511834e164e59d4cab110
-rw-r--r--cpio/mkbootfs.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/cpio/mkbootfs.c b/cpio/mkbootfs.c
index b89c3952c..e52762e9b 100644
--- a/cpio/mkbootfs.c
+++ b/cpio/mkbootfs.c
@@ -301,6 +301,7 @@ static void read_canned_config(char* filename)
301 allocated *= 2; 301 allocated *= 2;
302 canned_config = (struct fs_config_entry*)realloc( 302 canned_config = (struct fs_config_entry*)realloc(
303 canned_config, allocated * sizeof(struct fs_config_entry)); 303 canned_config, allocated * sizeof(struct fs_config_entry));
304 if (canned_config == NULL) die("failed to reallocate memory");
304 } 305 }
305 306
306 struct fs_config_entry* cc = canned_config + used; 307 struct fs_config_entry* cc = canned_config + used;
@@ -320,6 +321,7 @@ static void read_canned_config(char* filename)
320 ++allocated; 321 ++allocated;
321 canned_config = (struct fs_config_entry*)realloc( 322 canned_config = (struct fs_config_entry*)realloc(
322 canned_config, allocated * sizeof(struct fs_config_entry)); 323 canned_config, allocated * sizeof(struct fs_config_entry));
324 if (canned_config == NULL) die("failed to reallocate memory");
323 } 325 }
324 canned_config[used].name = NULL; 326 canned_config[used].name = NULL;
325 327