summaryrefslogtreecommitdiff
path: root/pp_sys.c
diff options
context:
space:
mode:
authorNicholas Clark <nick@ccl4.org>2006-04-30 23:08:17 +0000
committerNicholas Clark <nick@ccl4.org>2006-04-30 23:08:17 +0000
commit4b0c4b6fb611d776b6e7507f70c235f361e01815 (patch)
tree45fa63c8de31e3bf3b7473505a39a556c2908b2b /pp_sys.c
parent15b8f96d46c4164722f0c24dfb7e92d280880305 (diff)
downloadperl-4b0c4b6fb611d776b6e7507f70c235f361e01815.tar.gz
Fix two errors found by Coverity.
p4raw-id: //depot/perl@28034
Diffstat (limited to 'pp_sys.c')
-rw-r--r--pp_sys.c19
1 files changed, 14 insertions, 5 deletions
diff --git a/pp_sys.c b/pp_sys.c
index fdc99370c9..86061a693b 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;
}