Messages in this thread | | | Date | Mon, 9 Dec 2013 15:30:09 -0300 | From | Arnaldo Carvalho de Melo <> | Subject | Re: [PATCH 01/14] tools lib traceevent: Get rid of malloc_or_die() in show_error() |
| |
Em Mon, Dec 09, 2013 at 02:33:58PM +0900, Namhyung Kim escreveu: > Signed-off-by: Namhyung Kim <namhyung@kernel.org> > --- > tools/lib/traceevent/parse-filter.c | 16 +++++++++++++++- > 1 file changed, 15 insertions(+), 1 deletion(-) > > diff --git a/tools/lib/traceevent/parse-filter.c b/tools/lib/traceevent/parse-filter.c > index 2500e75583fc..0fc905c230ad 100644 > --- a/tools/lib/traceevent/parse-filter.c > +++ b/tools/lib/traceevent/parse-filter.c > @@ -56,7 +56,21 @@ static void show_error(char **error_str, const char *fmt, ...) > index = pevent_get_input_buf_ptr(); > len = input ? strlen(input) : 0; > > - error = malloc_or_die(MAX_ERR_STR_SIZE + (len*2) + 3); > + error = malloc(MAX_ERR_STR_SIZE + (len*2) + 3); > + if (error == NULL) { > + /* > + * Maybe it's due to len is too long. > + * Retry without the input buffer part. > + */ > + len = 0; > + > + error = malloc(MAX_ERR_STR_SIZE); > + if (error == NULL) { > + /* no memory */ > + *error_str = "failed to allocate memory"; > + return;
Can *error_str point to either malloc'ed or constant strings? Who releases the allocated memory?
- Arnaldo
> + } > + } > > if (len) { > strcpy(error, input); > -- > 1.7.11.7
| |