mail: Fix potential memory leak
Fix memory leak when realloc() failed. Pointed out by Clang Static Analyzer. Change-Id: I13f758c4d89275651e22785652d0880a6d5b1a8e Reviewed-on: https://review.haiku-os.org/c/1064 Reviewed-by: Adrien Destugues <[email protected]>
This commit is contained in:
committed by
waddlesplash
parent
d938c7118f
commit
a31244d098
@@ -3090,11 +3090,16 @@ TTextView::AddQuote(int32 start, int32 finish)
|
|||||||
// add quote to this line
|
// add quote to this line
|
||||||
int32 lineLength = index - lastLine + 1;
|
int32 lineLength = index - lastLine + 1;
|
||||||
|
|
||||||
target = (char *)realloc(target, targetLength + lineLength + quoteLength);
|
char* newTarget = (char *)realloc(target,
|
||||||
if (target == NULL) {
|
targetLength + lineLength + quoteLength);
|
||||||
// free the old buffer?
|
if (newTarget == NULL) {
|
||||||
|
// free the old buffer
|
||||||
|
free(target);
|
||||||
|
target = NULL;
|
||||||
free(text);
|
free(text);
|
||||||
return;
|
return;
|
||||||
|
} else {
|
||||||
|
target = newTarget;
|
||||||
}
|
}
|
||||||
|
|
||||||
// copy the quote sign
|
// copy the quote sign
|
||||||
|
|||||||
Reference in New Issue
Block a user