mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-02-05 22:47:48 +08:00
snprintf off by one.
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:
committed by
facebook-github-bot-7
parent
0f9c88514c
commit
0b15418d92
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user