1
0
mirror of https://gitlab.xiph.org/xiph/icecast-server.git synced 2024-06-23 06:25:24 +00:00

Feature: Replaced free()-strdup() in event code with util_replace_string()

See: #2370
This commit is contained in:
Philipp Schafft 2019-01-09 09:29:56 +00:00
parent edd3dcc60d
commit a301a302ba
3 changed files with 4 additions and 16 deletions

View File

@ -275,10 +275,7 @@ int event_get_exec(event_registration_t *er, config_options_t *options) {
* <option name="default_arguments" value="..." /> (for values see near top of documment) * <option name="default_arguments" value="..." /> (for values see near top of documment)
*/ */
if (strcmp(cur->name, "executable") == 0) { if (strcmp(cur->name, "executable") == 0) {
free(self->executable); util_replace_string(&(self->executable), cur->value);
self->executable = NULL;
if (cur->value)
self->executable = strdup(cur->value);
} else if (strcmp(cur->name, "default_arguments") == 0) { } else if (strcmp(cur->name, "default_arguments") == 0) {
self->argvtype = __str2argvtype(cur->value); self->argvtype = __str2argvtype(cur->value);
} else { } else {

View File

@ -64,10 +64,7 @@ int event_get_log(event_registration_t *er, config_options_t *options) {
* <option name="level" value="..." /> * <option name="level" value="..." />
*/ */
if (strcmp(options->name, "prefix") == 0) { if (strcmp(options->name, "prefix") == 0) {
free(self->prefix); util_replace_string(&(self->prefix), options->value);
self->prefix = NULL;
if (options->value)
self->prefix = strdup(options->value);
} else if (strcmp(options->name, "level") == 0) { } else if (strcmp(options->name, "level") == 0) {
self->level = ICECAST_LOGLEVEL_INFO; self->level = ICECAST_LOGLEVEL_INFO;
if (options->value) if (options->value)

View File

@ -122,19 +122,13 @@ int event_get_url(event_registration_t *er, config_options_t *options) {
* <option name="action" value="..." /> * <option name="action" value="..." />
*/ */
if (strcmp(options->name, "url") == 0) { if (strcmp(options->name, "url") == 0) {
free(self->url); util_replace_string(&(self->url), options->value);
self->url = NULL;
if (options->value)
self->url = strdup(options->value);
} else if (strcmp(options->name, "username") == 0) { } else if (strcmp(options->name, "username") == 0) {
username = options->value; username = options->value;
} else if (strcmp(options->name, "password") == 0) { } else if (strcmp(options->name, "password") == 0) {
password = options->value; password = options->value;
} else if (strcmp(options->name, "action") == 0) { } else if (strcmp(options->name, "action") == 0) {
free(self->action); util_replace_string(&(self->action), options->value);
self->action = NULL;
if (options->value)
self->action = strdup(options->value);
} else { } else {
ICECAST_LOG_ERROR("Unknown <option> tag with name %s.", options->name); ICECAST_LOG_ERROR("Unknown <option> tag with name %s.", options->name);
} }