Subject: | Segfault during 'make test' with FreeBSD 5.4/Perl5.8.6 with 64 bit ints |
IPC::ShareLite segfaults during make test, while in the read_share xs
function. This happens when zero length items are fed into sv_usepvn.
This patch seems to fix it, but was knocked up quickly so should be
applied with caution and further testing.
diff -u IPC-ShareLite-0.09/ShareLite.xs IPC-ShareLite-0.09_fixed/
ShareLite.xs
--- IPC-ShareLite-0.09/ShareLite.xs Sat Jul 15 10:59:52 2000
+++ IPC-ShareLite-0.09_fixed/ShareLite.xs Wed Feb 15 18:30:08 2006
@@ -335,12 +335,17 @@
char* data;
int length;
CODE:
- share = (Share *)SvIV(ST(0));
length = read_share(share, &data);
- ST(0) = sv_newmortal();
- if (length >= 0) {
- sv_usepvn((SV*)ST(0), data, length);
- } else {
+ if (length > 0) {
+ ST(0) = sv_2mortal(newSVpv(data, length));
+ free(data);
+ }
+ else if (length == 0) {
+ ST(0) = sv_2mortal(newSVpv("", 0));
+ free(data); /* XXX? */
+ }
+ else {
+ ST(0) = sv_newmortal();
sv_setsv(ST(0), &PL_sv_undef);
}
diff -u IPC-ShareLite-0.09/typemap IPC-ShareLite-0.09_fixed/typemap
--- IPC-ShareLite-0.09/typemap Fri Apr 14 10:23:54 2000
+++ IPC-ShareLite-0.09_fixed/typemap Wed Feb 15 17:29:22 2006
@@ -1,14 +1,11 @@
TYPEMAP
-Share* SHARE
+Share* T_PTROBJ
key_t KEY
INPUT
-SHARE
- $var = (Share *)SvIV($arg);
KEY
$var = (key_t) SvIV($arg);
OUTPUT
-SHARE
- sv_setiv($arg, (I32) $var);
+