[PATCH] acpica: handle realloc failures in fwts_acpica_vprintf()

Keng-Yü Lin kengyu at canonical.com
Fri Mar 9 05:38:49 UTC 2012


On Fri, Mar 9, 2012 at 8:59 AM, Colin King <colin.king at canonical.com> wrote:
> From: Colin Ian King <colin.king at canonical.com>
>
> Signed-off-by: Colin Ian King <colin.king at canonical.com>
> ---
>  src/acpica/fwts_acpica.c |   10 ++++++++--
>  1 files changed, 8 insertions(+), 2 deletions(-)
>
> diff --git a/src/acpica/fwts_acpica.c b/src/acpica/fwts_acpica.c
> index 096683a..609dc8f 100644
> --- a/src/acpica/fwts_acpica.c
> +++ b/src/acpica/fwts_acpica.c
> @@ -277,11 +277,17 @@ void fwts_acpica_vprintf(const char *fmt, va_list args)
>        if (buffer_len == 0) {
>                buffer_len = tmp_len + 1;
>                buffer = malloc(buffer_len);
> -               strcpy(buffer, tmp);
> +               if (buffer)
> +                       strcpy(buffer, tmp);
> +               else
> +                       buffer_len = 0;
>        } else {
>                buffer_len += tmp_len;
>                buffer = realloc(buffer, buffer_len);
> -               strcat(buffer, tmp);
> +               if (buffer)
> +                       strcat(buffer, tmp);
> +               else
> +                       buffer_len = 0;
>        }
>
>        if (index(buffer, '\n') != NULL) {
> --
> 1.7.9
>
Acked-by: Keng-Yu Lin <kengyu at canonical.com>


More information about the fwts-devel mailing list