diff --git a/java/jni/YGJNIVanilla.cpp b/java/jni/YGJNIVanilla.cpp index 1f0dd1c4a8..26511ca078 100644 --- a/java/jni/YGJNIVanilla.cpp +++ b/java/jni/YGJNIVanilla.cpp @@ -139,7 +139,9 @@ static int YGJNILogFunc( void* /*layoutContext*/, const char* format, va_list args) { - int result = vsnprintf(NULL, 0, format, args); + va_list argsCopy; + va_copy(argsCopy, args); + int result = vsnprintf(nullptr, 0, format, argsCopy); std::vector buffer(1 + result); vsnprintf(buffer.data(), buffer.size(), format, args);