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/error.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/error.c')
-rw-r--r-- | src/common/error.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/src/common/error.c b/src/common/error.c index 03695e7..caf47c3 100644 --- a/src/common/error.c +++ b/src/common/error.c @@ -26,6 +26,8 @@ bc_error_new(bc_error_type_t type, const char *msg) bc_error_t* bc_error_new_printf(bc_error_type_t type, const char *format, ...) { + if (format == NULL) + return bc_error_new(type, ""); va_list ap; va_start(ap, format); char *tmp = bc_strdup_vprintf(format, ap); @@ -40,6 +42,8 @@ bc_error_t* bc_error_parser(bc_error_type_t type, const char *src, size_t src_len, size_t current, const char *format, ...) { + if (format == NULL) + return bc_error_new(type, ""); va_list ap; va_start(ap, format); char *msg = bc_strdup_vprintf(format, ap); |