summaryrefslogtreecommitdiff
path: root/shared
diff options
context:
space:
mode:
authorBryce Harrington <bryce@osg.samsung.com>2016-02-17 20:46:01 -0800
committerBryce Harrington <bryce@osg.samsung.com>2016-02-22 13:30:51 -0800
commit3f2062ccb2bd6234ef5d47ccbea7f3b07f687eac (patch)
treeddb9d52d989ad206c03d12b9b6c9e38b53154553 /shared
parent58b7a156c5cddc11fe5a5e3f982d65d433a9177a (diff)
downloadweston-3f2062ccb2bd6234ef5d47ccbea7f3b07f687eac.tar.gz
config-parser: Check malloc and strdup returns
Signed-off-by: Bryce Harrington <bryce@osg.samsung.com> Reviewed-by: Marek Chalupa <mchqwerty@gmail.com>
Diffstat (limited to 'shared')
-rw-r--r--shared/config-parser.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/shared/config-parser.c b/shared/config-parser.c
index a50773ba..22564697 100644
--- a/shared/config-parser.c
+++ b/shared/config-parser.c
@@ -312,7 +312,15 @@ config_add_section(struct weston_config *config, const char *name)
struct weston_config_section *section;
section = malloc(sizeof *section);
+ if (section == NULL)
+ return NULL;
+
section->name = strdup(name);
+ if (section->name == NULL) {
+ free(section);
+ return NULL;
+ }
+
wl_list_init(&section->entry_list);
wl_list_insert(config->section_list.prev, &section->link);
@@ -326,8 +334,22 @@ section_add_entry(struct weston_config_section *section,
struct weston_config_entry *entry;
entry = malloc(sizeof *entry);
+ if (entry == NULL)
+ return NULL;
+
entry->key = strdup(key);
+ if (entry->key == NULL) {
+ free(entry);
+ return NULL;
+ }
+
entry->value = strdup(value);
+ if (entry->value == NULL) {
+ free(entry->key);
+ free(entry);
+ return NULL;
+ }
+
wl_list_insert(section->entry_list.prev, &entry->link);
return entry;