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
+3
View File
@@ -11,6 +11,8 @@
#include <stdint.h>
#include <sys/types.h>
#include "macro.h"
struct strbuf {
char *buf;
size_t len;
@@ -40,3 +42,4 @@ struct strbuf *strbuf_new(void);
ssize_t strbuf_add_string(struct strbuf *str, const char *s, size_t len);
void strbuf_complete(struct strbuf *str);
void strbuf_cleanup(struct strbuf *str);
DEFINE_TRIVIAL_CLEANUP_FUNC(struct strbuf*, strbuf_cleanup);