Browse Source

add missing null pointer check after malloc

Felix Fietkau 14 years ago
parent
commit
7b75c2af80
1 changed files with 3 additions and 0 deletions
  1. 3 0
      libuci.c

+ 3 - 0
libuci.c

@@ -55,6 +55,9 @@ struct uci_context *uci_alloc_context(void)
 	struct uci_context *ctx;
 
 	ctx = (struct uci_context *) malloc(sizeof(struct uci_context));
+	if (!ctx)
+		return NULL;
+
 	memset(ctx, 0, sizeof(struct uci_context));
 	uci_list_init(&ctx->root);
 	uci_list_init(&ctx->history_path);