Commit 1179355d authored by Martin Pool's avatar Martin Pool

Revert change from 1.39, because it causes a crash because of

attempting to free a static string.  (Thankyou to Paul Mackerras.)
There's still a small leak here.
parent 3d807132
...@@ -386,9 +386,16 @@ static void init_service(service *pservice) ...@@ -386,9 +386,16 @@ static void init_service(service *pservice)
/** /**
* Assign a copy of @p v to @p *s, freeing any existing values and * Assign a copy of @p v to @p *s. Handles NULL strings. @p *v must
* handling NULL strings. @p *v must be initialized when this is * be initialized when this is called, either to NULL or a malloc'd
* called, either to NULL or a malloc'd string. * string.
*
* @fixme There is a small leak here in that sometimes the existing
* value will be dynamically allocated, and the old copy is lost.
* However, we can't always deallocate the old value, because in the
* case of sDefault, it points to a static string. It would be nice
* to have either all-strdup'd values, or to never need to free
* memory.
**/ **/
static void string_set(char **s, const char *v) static void string_set(char **s, const char *v)
{ {
...@@ -396,8 +403,6 @@ static void string_set(char **s, const char *v) ...@@ -396,8 +403,6 @@ static void string_set(char **s, const char *v)
*s = NULL; *s = NULL;
return; return;
} }
if (*s)
free(*s);
*s = strdup(v); *s = strdup(v);
if (!*s) if (!*s)
exit_cleanup(RERR_MALLOC); exit_cleanup(RERR_MALLOC);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment