Re: [PATCH 09/11] parse-filter: Check result of malloc() duringreading token

From: Steven Rostedt
Date: Mon Apr 23 2012 - 14:48:36 EST


On Mon, 2012-04-23 at 13:58 +0900, Namhyung Kim wrote:
> The malloc can fail so the return value should be checked.
> For now, just use malloc_or_die().

Applied, thanks!

Although we will be getting rid of the 'die' feature. But at least this
marks a location that we need to track.

-- Steve

>
> Signed-off-by: Namhyung Kim <namhyung.kim@xxxxxxx>
> ---
> parse-filter.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/parse-filter.c b/parse-filter.c
> index bc62f1f..0e6c0b1 100644
> --- a/parse-filter.c
> +++ b/parse-filter.c
> @@ -96,7 +96,7 @@ static enum event_type read_token(char **tok)
> (strcmp(token, "=") == 0 || strcmp(token, "!") == 0) &&
> pevent_peek_char() == '~') {
> /* append it */
> - *tok = malloc(3);
> + *tok = malloc_or_die(3);
> sprintf(*tok, "%c%c", *token, '~');
> free_token(token);
> /* Now remove the '~' from the buffer */


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/