Introduce _cleanup_(strbuf_cleanupp) and use it to fix null deref on error

catalog_update() would call strbuf_cleanup(NULL) on allocation error.
CID #1390928.
This commit is contained in:
Zbigniew Jędrzejewski-Szmek
2018-05-10 01:36:50 +02:00
parent db983479af
commit f201daec89
4 changed files with 24 additions and 39 deletions
+1 -3
View File
@@ -18,7 +18,7 @@ static ssize_t add_string(struct strbuf *sb, const char *s) {
}
static void test_strbuf(void) {
struct strbuf *sb;
_cleanup_(strbuf_cleanupp) struct strbuf *sb;
_cleanup_strv_free_ char **l;
ssize_t a, b, c, d, e, f, g, h;
@@ -72,8 +72,6 @@ static void test_strbuf(void) {
strbuf_complete(sb);
assert_se(sb->root == NULL);
strbuf_cleanup(sb);
}
int main(int argc, const char *argv[]) {