[PATCH] lib: fwts_tag: handle out of memory failure
Alex Hung
alex.hung at canonical.com
Wed Mar 7 09:52:08 UTC 2012
On 03/02/2012 06:01 PM, Colin King wrote:
> From: Colin Ian King<colin.king at canonical.com>
>
> Signed-off-by: Colin Ian King<colin.king at canonical.com>
> ---
> src/lib/src/fwts_tag.c | 6 ++++--
> 1 files changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/src/lib/src/fwts_tag.c b/src/lib/src/fwts_tag.c
> index 76c84ec..24e0b53 100644
> --- a/src/lib/src/fwts_tag.c
> +++ b/src/lib/src/fwts_tag.c
> @@ -158,11 +158,13 @@ char *fwts_tag_list_to_str(fwts_list *taglist)
> len += taglen + 1;
>
> if (str) {
> - str = realloc(str, len);
> + if ((str = realloc(str, len)) == NULL)
> + return NULL;
> strcat(str, " ");
> strcat(str, tag);
> } else {
> - str = malloc(len);
> + if ((str = malloc(len)) == NULL)
> + return NULL;
> strcpy(str, tag);
> }
> }
Acked-by: Alex Hung <alex.hung at canonical.com>
More information about the fwts-devel
mailing list