Welcome to little lamb

Code » anopa » commit f6cd600

status: Fix stupid error introduced in ef3bb9da

author Olivier Brunel
2018-02-23 18:57:34 UTC
committer Olivier Brunel
2018-02-23 18:59:03 UTC
parent 95e098e37c16610f45c32e128c81d445f75b0f83

status: Fix stupid error introduced in ef3bb9da

stralloc_cats() doesn't include the NUL terminating byte, so if memory
didn't happen to be zero before this would fail...

src/anopa/aa-enable.c +3 -3
src/anopa/aa-status.c +1 -1

diff --git a/src/anopa/aa-enable.c b/src/anopa/aa-enable.c
index 362e7c6..517fb85 100644
--- a/src/anopa/aa-enable.c
+++ b/src/anopa/aa-enable.c
@@ -210,9 +210,9 @@ copy_file (const char *src, const char *dst)
 
     if (*src != '/')
     {
-        if (!stralloc_cats (&sa_pl, "/"))
-            aa_strerr_diefu1sys (RC_FATAL_MEMORY, "stralloc_cats");
-        if (!stralloc_cats (&sa_pl, src))
+        if (!stralloc_cats (&sa_pl, "/")
+                || !stralloc_cats (&sa_pl, src)
+                || !stralloc_0 (&sa_pl))
             aa_strerr_diefu1sys (RC_FATAL_MEMORY, "stralloc_cats");
         src = sa_pl.s;
     }
diff --git a/src/anopa/aa-status.c b/src/anopa/aa-status.c
index 395a6b5..d6bdfff 100644
--- a/src/anopa/aa-status.c
+++ b/src/anopa/aa-status.c
@@ -955,7 +955,7 @@ main (int argc, char * const argv[])
     if (all)
     {
         sacwd.len = 0;
-        stralloc_cats (&sacwd, ".");
+        stralloc_catb (&sacwd, ".", 2);
         r = aa_scan_dir (&sacwd, 0, it_all, &cfg);
         if (r < 0)
             aa_strerr_diefu2sys (RC_FATAL_IO, "scan repo directory ", path_repo);