Radish alpha
H
rad:z3QDZAW2FAfuLvihrhiyDC9fAD8G9
HardenedBSD Package Manager
Radicle
Git
Plug a memory leak, check the return of a malloc
Baptiste Daroussin committed 10 years ago
commit e1d2e2974f764b60eb5f7f0e456d537d50a5d7a3
parent fea9e8a
1 file changed +4 -1
modified libpkg/pkg_ports.c
@@ -895,6 +895,9 @@ apply_keyword_file(ucl_object_t *obj, struct plist *p, char *line, struct file_a
	if ((o = ucl_object_find_key(obj,  "arguments")) && ucl_object_toboolean(o)) {
		spaces = pkg_utils_count_spaces(line);
		args = malloc((spaces + 1)* sizeof(char *));
+
		if (args != NULL) {
+
			return (EPKG_FATAL);
+
		}
		tofree = buf = strdup(line);
		while (buf != NULL) {
			args[argc++] = pkg_utils_tokenize(&buf);
@@ -907,7 +910,7 @@ apply_keyword_file(ucl_object_t *obj, struct plist *p, char *line, struct file_a
	if ((o = ucl_object_find_key(obj, "pre-install"))) {
		if (format_exec_cmd(&cmd, ucl_object_tostring(o), p->prefix,
		    p->last_file, line, argc, args) != EPKG_OK)
-
			return (EPKG_FATAL);
+
			goto keywords_cleanup;
		sbuf_printf(p->pre_install_buf, "%s\n", cmd);
		free(cmd);
	}