Summary:
According to `man snprintf`

    Upon successful return, these functions return the number of
    characters printed (not including the trailing '\0' used to end
    output to strings).

Or am I misunderstanding something about what's going on here?

public

Reviewed By: zlern2k, dcolascione

Differential Revision: D2805759

fb-gh-sync-id: f20908f80cdfff9677fe38c7c1cf733f0f5b1c5e
This commit is contained in:
Michael Lee 2016-01-06 13:01:24 -08:00 коммит произвёл facebook-github-bot-7
Родитель 0f9c88514c
Коммит 0b15418d92
2 изменённых файлов: 2 добавлений и 2 удалений

Просмотреть файл

@ -193,7 +193,7 @@ void setNewJavaException(jclass exceptionClass, const char* fmt, ARGS... args) {
JNIEnv* env = internal::getEnv();
try {
char *msg = (char*) alloca(msgSize);
char *msg = (char*) alloca(msgSize + 1);
snprintf(msg, kMaxExceptionMessageBufferSize, fmt, args...);
env->ThrowNew(exceptionClass, msg);
} catch (...) {

Просмотреть файл

@ -114,7 +114,7 @@ template<typename... Args>
assertIfExceptionsNotInitialized();
int msgSize = snprintf(nullptr, 0, fmt, args...);
char *msg = (char*) alloca(msgSize);
char *msg = (char*) alloca(msgSize + 1);
snprintf(msg, kMaxExceptionMessageBufferSize, fmt, args...);
throwNewJavaException(throwableName, msg);
}