-
-
Save jasonbking/9ba5f528f7c08c290692794a51a2ddab to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/usr/src/lib/libcustr/common/custr.c b/usr/src/lib/libcustr/common/custr.c | |
index 8c8288ab7d..110a2be1b6 100644 | |
--- a/usr/src/lib/libcustr/common/custr.c | |
+++ b/usr/src/lib/libcustr/common/custr.c | |
@@ -110,10 +110,13 @@ custr_cstr(custr_t *cus) | |
int | |
custr_append_vprintf(custr_t *cus, const char *fmt, va_list ap) | |
{ | |
- int len = vsnprintf(NULL, 0, fmt, ap); | |
+ va_list copy; | |
+ int len; | |
size_t chunksz = STRING_CHUNK_SIZE; | |
- if (len < 0) { | |
+ va_copy(copy, ap); | |
+ | |
+ if ((len = vsnprintf(NULL, 0, fmt, ap)) < 0) { | |
return (len); | |
} | |
@@ -157,7 +160,7 @@ custr_append_vprintf(custr_t *cus, const char *fmt, va_list ap) | |
* Append new string to existing string: | |
*/ | |
if ((len = vsnprintf(cus->cus_data + cus->cus_strlen, | |
- cus->cus_datalen - cus->cus_strlen, fmt, ap)) < 0) { | |
+ cus->cus_datalen - cus->cus_strlen, fmt, copy)) < 0) { | |
return (len); | |
} | |
cus->cus_strlen += len; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment