Welcome to little lamb

Code » anopa » commit 95e098e

Fix possibly missing OOM errors

author Olivier Brunel
2018-02-23 18:53:41 UTC
committer Olivier Brunel
2018-02-23 18:59:03 UTC
parent ca18669f9dcb8c74f1e9c61aa6c92c0bfa572e5c

Fix possibly missing OOM errors

stralloc_cats() never returns < 0, so this would never catch a failure.

src/libanopa/enable_service.c +4 -7

diff --git a/src/libanopa/enable_service.c b/src/libanopa/enable_service.c
index f0127da..686c8b4 100644
--- a/src/libanopa/enable_service.c
+++ b/src/libanopa/enable_service.c
@@ -130,13 +130,10 @@ clear_dir (const char *path, int excludes, aa_warn_fn warn_fn)
                 && (d->d_name[1] == '\0' || (d->d_name[1] == '.' && d->d_name[2] == '\0')))
             continue;
 
-        if (stralloc_cats (&satmp, path) < 0)
-            goto err;
-        if (stralloc_catb (&satmp, "/", 1) < 0)
-            goto err;
-        if (stralloc_cats (&satmp, d->d_name) < 0)
-            goto err;
-        if (!stralloc_0 (&satmp))
+        if (!stralloc_cats (&satmp, path)
+                || !stralloc_cats (&satmp, "/")
+                || !stralloc_cats (&satmp, d->d_name)
+                || !stralloc_0 (&satmp))
             goto err;
 
         if (d->d_type == DT_UNKNOWN)