]> git.ozlabs.org Git - ccan/blobdiff - ccan/opt/usage.c
opt: avoid bad access on empty usage message, free all mem in tests.
[ccan] / ccan / opt / usage.c
index 12f44a48752e0e0d4e0d722c74b7513561334733..8ee4ebd03ad5083e2f8a36649319190edb14e7b5 100644 (file)
@@ -72,7 +72,8 @@ static size_t consume_words(const char *words, size_t maxlen, size_t *prefix,
                }
        }
 
-       *start = (words[oldlen - 1] == '\n');
+       if (oldlen != 0)
+               *start = (words[oldlen - 1] == '\n');
        return oldlen;
 }