From c50f40dd3426f3b768d05bcc8ddb886ee1d2cb6f Mon Sep 17 00:00:00 2001 From: rswindell <> Date: Wed, 2 Nov 2011 23:27:23 +0000 Subject: [PATCH] Fix potential memory leaks on malloc() failure. --- src/sbbs3/wordwrap.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/sbbs3/wordwrap.c b/src/sbbs3/wordwrap.c index 0c1dfbddd6..e2da78a96e 100644 --- a/src/sbbs3/wordwrap.c +++ b/src/sbbs3/wordwrap.c @@ -4,7 +4,7 @@ * @format.tab-size 4 (Plain Text/Source Code File Header) * * @format.use-tabs true (see http://www.synchro.net/ptsc_hdr.html) * * * - * Copyright 2010 Rob Swindell - http://www.synchro.net/copyright.html * + * Copyright 2011 Rob Swindell - http://www.synchro.net/copyright.html * * * * This program is free software; you can redistribute it and/or * * modify it under the terms of the GNU General Public License * @@ -191,12 +191,15 @@ char* wordwrap(char* inbuf, int len, int oldlen, BOOL handle_quotes) return NULL; outp=outbuf; - if((linebuf=(char*)malloc(inbuf_len+2))==NULL) /* room for ^A codes */ + if((linebuf=(char*)malloc(inbuf_len+2))==NULL) { /* room for ^A codes */ + free(outbuf); return NULL; + } if(handle_quotes) { if((prefix=(char *)malloc(inbuf_len+1))==NULL) { /* room for ^A codes */ free(linebuf); + free(outbuf); return NULL; } prefix[0]=0; -- GitLab