LocalString doesn't have a check for nullptr

Summary:
LocalString doesn't have a check for null ptr which causes a crash if the null string passed.
Closes https://github.com/facebook/react-native/pull/15372

Differential Revision: D5601469

Pulled By: javache

fbshipit-source-id: a1b20efbae90009f0d465c077e6401a701d7515f
This commit is contained in:
Sergei Dryganets 2017-08-10 03:09:46 -07:00 committed by Facebook Github Bot
parent 92dd6b9c9d
commit 7e515479b0

View File

@ -82,6 +82,7 @@ size_t modifiedLength(const uint8_t* str, size_t* length) {
// NUL-terminated: Scan for length and supplementary characters
size_t i = 0;
size_t j = 0;
if (str != nullptr) {
while (str[i] != 0) {
if (str[i + 1] == 0 ||
str[i + 2] == 0 ||
@ -94,6 +95,7 @@ size_t modifiedLength(const uint8_t* str, size_t* length) {
j += 6;
}
}
}
*length = i;
return j;