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
|
||||
int32 lineLength = index - lastLine + 1;
|
||||
|
||||
target = (char *)realloc(target, targetLength + lineLength + quoteLength);
|
||||
if (target == NULL) {
|
||||
// free the old buffer?
|
||||
char* newTarget = (char *)realloc(target,
|
||||
targetLength + lineLength + quoteLength);
|
||||
if (newTarget == NULL) {
|
||||
// free the old buffer
|
||||
free(target);
|
||||
target = NULL;
|
||||
free(text);
|
||||
return;
|
||||
} else {
|
||||
target = newTarget;
|
||||
}
|
||||
|
||||
// copy the quote sign
|
||||
|
||||
Reference in New Issue
Block a user