v may get incremented, so be sure to save the ''original'' strdup'ed
pointer and free ''that'' -- not the (possibly incremented) pointer This commit was SVN r25425.
Этот коммит содержится в:
родитель
7595a80a63
Коммит
6139256e45
@ -59,7 +59,7 @@ void ompi_info_out(const char *pretty_message, const char *plain_message, const
|
||||
size_t i, len, max_value_width;
|
||||
char *spaces = NULL;
|
||||
char *filler = NULL;
|
||||
char *pos, *v, savev;
|
||||
char *pos, *v, savev, *v_to_free;
|
||||
|
||||
#ifdef HAVE_ISATTY
|
||||
/* If we have isatty(), if this is not a tty, then disable
|
||||
@ -80,7 +80,7 @@ void ompi_info_out(const char *pretty_message, const char *plain_message, const
|
||||
#endif
|
||||
|
||||
/* Strip leading and trailing whitespace from the string value */
|
||||
v = strdup(value);
|
||||
v = v_to_free = strdup(value);
|
||||
len = strlen(v);
|
||||
if (isspace(v[0])) {
|
||||
char *newv;
|
||||
@ -186,8 +186,8 @@ void ompi_info_out(const char *pretty_message, const char *plain_message, const
|
||||
printf(" %s\n", value);
|
||||
}
|
||||
}
|
||||
if (NULL != v) {
|
||||
free(v);
|
||||
if (NULL != v_to_free) {
|
||||
free(v_to_free);
|
||||
}
|
||||
}
|
||||
|
||||
|
Загрузка…
x
Ссылка в новой задаче
Block a user