[PATCH] acpica: handle realloc failures in fwts_acpica_vprintf()
Alex Hung
alex.hung at canonical.com
Fri Mar 9 02:12:19 UTC 2012
On 03/09/2012 08:59 AM, Colin King 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) {
Acked-by: Alex Hung <alex.hung at canonical.com>
More information about the fwts-devel
mailing list