From patchwork Fri Mar 9 00:59:50 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Colin Ian King X-Patchwork-Id: 145636 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from chlorine.canonical.com (chlorine.canonical.com [91.189.94.204]) by ozlabs.org (Postfix) with ESMTP id CCC4FB6FA8 for ; Fri, 9 Mar 2012 11:59:54 +1100 (EST) Received: from localhost ([127.0.0.1] helo=chlorine.canonical.com) by chlorine.canonical.com with esmtp (Exim 4.71) (envelope-from ) id 1S5oBV-0007Oa-EZ for incoming@patchwork.ozlabs.org; Fri, 09 Mar 2012 00:59:53 +0000 Received: from youngberry.canonical.com ([91.189.89.112]) by chlorine.canonical.com with esmtp (Exim 4.71) (envelope-from ) id 1S5oBT-0007OS-Pd for fwts-devel@lists.ubuntu.com; Fri, 09 Mar 2012 00:59:51 +0000 Received: from cpc19-craw6-2-0-cust5.croy.cable.virginmedia.com ([77.102.228.6] helo=localhost) by youngberry.canonical.com with esmtpsa (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1S5oBT-00073c-Kz for fwts-devel@lists.ubuntu.com; Fri, 09 Mar 2012 00:59:51 +0000 From: Colin King To: fwts-devel@lists.ubuntu.com Subject: [PATCH] acpica: handle realloc failures in fwts_acpica_vprintf() Date: Fri, 9 Mar 2012 00:59:50 +0000 Message-Id: <1331254790-30221-1-git-send-email-colin.king@canonical.com> X-Mailer: git-send-email 1.7.9 X-BeenThere: fwts-devel@lists.ubuntu.com X-Mailman-Version: 2.1.13 Precedence: list List-Id: Firmware Test Suite Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: fwts-devel-bounces@lists.ubuntu.com Errors-To: fwts-devel-bounces@lists.ubuntu.com From: Colin Ian King Signed-off-by: Colin Ian King Acked-by: Alex Hung Acked-by: Keng-Yu Lin --- 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) {