]> git.ipfire.org Git - thirdparty/libarchive.git/commitdiff
Fix the potential of memory leaks in our test suit, which
authorMichihiro NAKAJIMA <ggcueroad@gmail.com>
Sun, 5 Oct 2014 01:12:04 +0000 (10:12 +0900)
committerMichihiro NAKAJIMA <ggcueroad@gmail.com>
Sun, 5 Oct 2014 01:12:04 +0000 (10:12 +0900)
Xcode Analyzer pointed out.

libarchive/test/test_write_disk_appledouble.c
libarchive/test/test_write_disk_hfs_compression.c
libarchive/test/test_write_disk_mac_metadata.c
libarchive/test/test_write_disk_no_hfs_compression.c

index d604fbf2d51b59b2e0e42a943a016941a5107a6a..4f1850b3df4db307e58ae46ac1517058d6a337cf 100644 (file)
@@ -48,8 +48,8 @@ has_xattr(const char *filename, const char *xattrname)
        if (r == 0)
                return (0);
 
-       nl = malloc(r);
-       if (!assert(nl != NULL))
+       assert((nl = malloc(r)) != NULL);
+       if (nl == NULL)
                return (0);
 
        r = listxattr(filename, nl, r, XATTR_SHOWCOMPRESSION);
index 24c13c4ed68a1818c99a43151fe6c515c557dbb4..2960fe2ed6dd0622c58abd123ee28c2cc29d9f1b 100644 (file)
@@ -45,8 +45,8 @@ has_xattr(const char *filename, const char *xattrname)
        if (r == 0)
                return (0);
 
-       nl = malloc(r);
-       if (!assert(nl != NULL))
+       assert((nl = malloc(r)) != NULL);
+       if (nl == NULL)
                return (0);
 
        r = listxattr(filename, nl, r, XATTR_SHOWCOMPRESSION);
index f9e47d6593639b6d0b4da20dae97b31e8355fb06..b834a58ed5cac19b41b79fe6e0affd31b2397b76 100644 (file)
@@ -48,8 +48,8 @@ has_xattr(const char *filename, const char *xattrname)
        if (r == 0)
                return (0);
 
-       nl = malloc(r);
-       if (!assert(nl != NULL))
+       assert((nl = malloc(r)) != NULL);
+       if (nl == NULL)
                return (0);
 
        r = listxattr(filename, nl, r, XATTR_SHOWCOMPRESSION);
index a1afb9bb290f0fdd5217790be5b35239d2dcfdd2..b7210e204a145bf57dd4e862069495d34ec7c6eb 100644 (file)
@@ -45,8 +45,8 @@ has_xattr(const char *filename, const char *xattrname)
        if (r == 0)
                return (0);
 
-       nl = malloc(r);
-       if (!assert(nl != NULL))
+       assert((nl = malloc(r)) != NULL);
+       if (nl == NULL)
                return (0);
 
        r = listxattr(filename, nl, r, XATTR_SHOWCOMPRESSION);