From patchwork Fri Mar 9 01:08:58 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: lib: fwts_args: handle realloc failure Date: Thu, 08 Mar 2012 15:08:58 -0000 From: Colin King X-Patchwork-Id: 145639 Message-Id: <1331255338-30892-1-git-send-email-colin.king@canonical.com> To: fwts-devel@lists.ubuntu.com From: Colin Ian King Signed-off-by: Colin Ian King Acked-by: Alex Hung Acked-by: Keng-Yu Lin --- src/lib/src/fwts_args.c | 6 ++++++ 1 files changed, 6 insertions(+), 0 deletions(-) diff --git a/src/lib/src/fwts_args.c b/src/lib/src/fwts_args.c index f72561c..90f3d70 100644 --- a/src/lib/src/fwts_args.c +++ b/src/lib/src/fwts_args.c @@ -127,6 +127,12 @@ int fwts_args_parse(fwts_framework *fw, int argc, char * const argv[]) if (short_options) { short_options = realloc(short_options, strlen(short_options) + len + 1); + if (short_options == NULL) { + fwts_log_error(fw, + "Out of memory " + "allocating options."); + return FWTS_ERROR; + } strcat(short_options, short_name); } else { short_options = calloc(1, len + 1);