libroot/os/driver_settings.cpp: fix memory leak
Fix leakage of memory allocated to 'text' when new_settings() fails in load_driver_settings() at line 767. Pointed out by Clang Static Analyzer. Change-Id: I5888e2377c4da63040d5a66199f04aebd2034728 Reviewed-on: https://review.haiku-os.org/c/haiku/+/6382 Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org> Reviewed-by: Jérôme Duval <jerome.duval@gmail.com>
This commit is contained in:
parent
cfbfb8473c
commit
18f35e4ebd
@ -764,7 +764,10 @@ load_driver_settings(const char *driverName)
|
||||
return NULL;
|
||||
|
||||
memcpy(text, settings->buffer, settings->size + 1);
|
||||
return new_settings(text, driverName);
|
||||
settings_handle *handle = new_settings(text, driverName);
|
||||
if (handle == NULL)
|
||||
free(text);
|
||||
return handle;
|
||||
}
|
||||
settings = settings->next;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user