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:
Adrien Destugues
2015-01-14 13:39:35 +01:00
parent bcb793d37b
commit 1736cb1d59
+7 -8
View File
@@ -828,21 +828,20 @@ 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
char *text = strdup(settingsString); text = strdup(settingsString);
if (text != NULL) { if (text == NULL)
return NULL;
}
settings_handle *handle = new_settings(text, NULL); settings_handle *handle = new_settings(text, NULL);
if (handle == NULL) if (handle == NULL)
free(text); free(text);
return handle; return handle;
} }
return NULL;
}
/*! /*!
This function prints out a driver settings structure to a human This function prints out a driver settings structure to a human