Fix several places where talloc_asprintf returns were unchecked.
authorJeremy Allison <jra@samba.org>
Tue, 27 Jul 2010 09:36:57 +0000 (02:36 -0700)
committerJeremy Allison <jra@samba.org>
Tue, 27 Jul 2010 09:38:14 +0000 (02:38 -0700)
Jeremy.

source3/lib/tdb_validate.c

index c5cb1b44d4c6a027782b38bfe1ddefde53ecfa3a..e001d9cb768af5fe64ac2449e7ce550fa75a6f85 100644 (file)
@@ -281,6 +281,11 @@ static int tdb_backup(TALLOC_CTX *ctx, const char *src_path,
        }
 
        tmp_path = talloc_asprintf(ctx, "%s%s", dst_path, ".tmp");
+       if (!tmp_path) {
+               DEBUG(3, ("talloc fail\n"));
+               goto done;
+       }
+
        unlink(tmp_path);
        dst_tdb = tdb_open_log(tmp_path,
                               hash_size ? hash_size : tdb_hash_size(src_tdb),
@@ -398,6 +403,10 @@ static int tdb_backup_with_rotate(TALLOC_CTX *ctx, const char *src_path,
        {
                char *rotate_path = talloc_asprintf(ctx, "%s%s", dst_path,
                                                    rotate_suffix);
+               if (rotate_path == NULL) {
+                       DEBUG(10, ("talloc fail\n"));
+                       return -1;
+               }
                DEBUG(10, ("backup of %s failed due to lack of space\n",
                           src_path));
                DEBUGADD(10, ("trying to free some space by removing rotated "
@@ -454,6 +463,10 @@ int tdb_validate_and_backup(const char *tdb_path,
        }
 
        tdb_path_backup = talloc_asprintf(ctx, "%s%s", tdb_path, backup_suffix);
+       if (!tdb_path_backup) {
+               DEBUG(0, ("tdb_validate_and_backup: out of memory\n"));
+               goto done;
+       }
 
        ret = tdb_validate_open(tdb_path, validate_fn);