From: Nicholas Clark Date: Sun, 30 Apr 2006 23:08:17 +0000 (+0000) Subject: Fix two errors found by Coverity. X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=4b0c4b6fb611d776b6e7507f70c235f361e01815;p=p5sagit%2Fp5-mst-13.2.git Fix two errors found by Coverity. p4raw-id: //depot/perl@28034 --- diff --git a/pp_sys.c b/pp_sys.c index fdc9937..86061a6 100644 --- a/pp_sys.c +++ b/pp_sys.c @@ -1885,18 +1885,24 @@ PP(pp_send) #else length = (Size_t)SvIVx(*++MARK); #endif - if ((SSize_t)length < 0) + if ((SSize_t)length < 0) { + Safefree(tmpbuf); DIE(aTHX_ "Negative length"); + } } if (MARK < SP) { offset = SvIVx(*++MARK); if (offset < 0) { - if (-offset > (IV)blen_chars) + if (-offset > (IV)blen_chars) { + Safefree(tmpbuf); DIE(aTHX_ "Offset outside string"); + } offset += blen_chars; - } else if (offset >= (IV)blen_chars && blen_chars > 0) + } else if (offset >= (IV)blen_chars && blen_chars > 0) { + Safefree(tmpbuf); DIE(aTHX_ "Offset outside string"); + } } else offset = 0; if (length > blen_chars - offset) @@ -1959,14 +1965,15 @@ PP(pp_send) else DIE(aTHX_ PL_no_sock_func, "send"); #endif - if (tmpbuf) - Safefree(tmpbuf); if (retval < 0) goto say_undef; SP = ORIGMARK; if (doing_utf8) retval = utf8_length((U8*)buffer, (U8*)buffer + retval); + + if (tmpbuf) + Safefree(tmpbuf); #if Size_t_size > IVSIZE PUSHn(retval); #else @@ -1975,6 +1982,8 @@ PP(pp_send) RETURN; say_undef: + if (tmpbuf) + Safefree(tmpbuf); SP = ORIGMARK; RETPUSHUNDEF; }