driver_settings: fix allocating an empty settings
I misread the condition and broke this in 0687a01. Thanks to Axel for
reviewing!
* Refactor the code again to move all the error checking at the top of
the function, to make it easier to read.
This commit is contained in:
@@ -828,19 +828,18 @@ load_driver_settings_file(int fd)
|
|||||||
void *
|
void *
|
||||||
parse_driver_settings_string(const char *settingsString)
|
parse_driver_settings_string(const char *settingsString)
|
||||||
{
|
{
|
||||||
if (settingsString == NULL)
|
char *text = NULL;
|
||||||
return NULL;
|
if (settingsString != NULL) {
|
||||||
|
// we simply copy the whole string to use it as our internal buffer
|
||||||
// we simply copy the whole string to use it as our internal buffer
|
text = strdup(settingsString);
|
||||||
char *text = strdup(settingsString);
|
if (text == NULL)
|
||||||
if (text != NULL) {
|
return NULL;
|
||||||
settings_handle *handle = new_settings(text, NULL);
|
|
||||||
if (handle == NULL)
|
|
||||||
free(text);
|
|
||||||
return handle;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return NULL;
|
settings_handle *handle = new_settings(text, NULL);
|
||||||
|
if (handle == NULL)
|
||||||
|
free(text);
|
||||||
|
return handle;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user