Commit d6fca0ba38c4b10064f9b966ab286a63acaf9ce9

Hiltjo Posthuma 2019-09-15T13:51:17

check calloc() for NULL return value

diff --git a/lib/repository.c b/lib/repository.c
index 2882ec4..6ee2cf1 100644
--- a/lib/repository.c
+++ b/lib/repository.c
@@ -1428,6 +1428,8 @@ import_subdir(struct got_tree_entry **new_te, struct dirent *de,
 		return got_error_from_errno("asprintf");
 
 	(*new_te) = calloc(1, sizeof(**new_te));
+	if (*new_te == NULL)
+		return got_error_from_errno("calloc");
 	(*new_te)->mode = S_IFDIR;
 	(*new_te)->name = strdup(de->d_name);
 	if ((*new_te)->name == NULL) {
diff --git a/lib/worktree.c b/lib/worktree.c
index 9ccc0f4..5f97bf0 100644
--- a/lib/worktree.c
+++ b/lib/worktree.c
@@ -3745,6 +3745,8 @@ make_subtree_for_added_blob(struct got_tree_entry **new_tep,
 		return got_error_from_errno("asprintf");
 
 	new_te = calloc(1, sizeof(*new_te));
+	if (new_te == NULL)
+		return got_error_from_errno("calloc");
 	new_te->mode = S_IFDIR;
 	new_te->name = strdup(child_path);
 	if (new_te->name == NULL) {