diff options
author | Rafael G. Martins <rafael@rafaelmartins.eng.br> | 2019-09-09 20:44:18 +0200 |
---|---|---|
committer | Rafael G. Martins <rafael@rafaelmartins.eng.br> | 2019-09-09 20:44:25 +0200 |
commit | a576156e5bf9de147efe2c76af1ee29f5efd773e (patch) | |
tree | a72f60f78cd4db77ce5d10d084b6d1c8e1e0fe27 /src/common/utils.c | |
parent | c9df78f02b66513c6e831d81c3240a715fee7e70 (diff) | |
download | blogc-a576156e5bf9de147efe2c76af1ee29f5efd773e.tar.gz blogc-a576156e5bf9de147efe2c76af1ee29f5efd773e.tar.bz2 blogc-a576156e5bf9de147efe2c76af1ee29f5efd773e.zip |
common: prevent stdarg errors when format is NULL
Diffstat (limited to 'src/common/utils.c')
-rw-r--r-- | src/common/utils.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/src/common/utils.c b/src/common/utils.c index 692d1ce..f686222 100644 --- a/src/common/utils.c +++ b/src/common/utils.c @@ -138,6 +138,8 @@ bc_strndup(const char *s, size_t n) char* bc_strdup_vprintf(const char *format, va_list ap) { + if (format == NULL) + return NULL; va_list ap2; va_copy(ap2, ap); int l = vsnprintf(NULL, 0, format, ap2); @@ -159,6 +161,8 @@ bc_strdup_vprintf(const char *format, va_list ap) char* bc_strdup_printf(const char *format, ...) { + if (format == NULL) + return NULL; va_list ap; va_start(ap, format); char *tmp = bc_strdup_vprintf(format, ap); @@ -464,6 +468,8 @@ bc_string_append_printf(bc_string_t *str, const char *format, ...) { if (str == NULL) return NULL; + if (format == NULL) + return str; va_list ap; va_start(ap, format); char *tmp = bc_strdup_vprintf(format, ap); |