diff --git a/src/xpath.c b/src/xpath.c index 309150beb..37e8d1e1d 100644 --- a/src/xpath.c +++ b/src/xpath.c @@ -236,7 +236,7 @@ print_expr_str(char **str, size_t *size, size_t *used, const char *format, ...) va_start(ap, format); /* try to append the string */ - p = vsnprintf(*str + *used, *size - *used, format, ap); + p = vsnprintf(*str ? *str + *used : NULL, *size - *used, format, ap); if ((unsigned)p >= *size - *used) { /* realloc */