diff options
Diffstat (limited to 'src/common')
| -rw-r--r-- | src/common/error.c | 4 | ||||
| -rw-r--r-- | src/common/utils.c | 6 | 
2 files changed, 10 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); 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);  | 
