support/String: Fix PVS 626
Fix memory leak when realloc() fails. Change-Id: I5b44df57bdd251e5164938ed70412c909ce09df1 Reviewed-on: https://review.haiku-os.org/c/1004 Reviewed-by: Adrien Destugues <[email protected]>
This commit is contained in:
committed by
waddlesplash
parent
e5d0c9094d
commit
6c67c7d635
@@ -2360,9 +2360,14 @@ BString::_Resize(int32 length)
|
||||
if (length < 0)
|
||||
length = 0;
|
||||
|
||||
data = (char*)realloc(data, length + kPrivateDataOffset + 1);
|
||||
if (data == NULL)
|
||||
char* newData = (char*)realloc(data, length + kPrivateDataOffset + 1);
|
||||
if (newData == NULL) {
|
||||
free(data);
|
||||
data = NULL;
|
||||
return NULL;
|
||||
} else {
|
||||
data = newData;
|
||||
}
|
||||
|
||||
data += kPrivateDataOffset;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user