DIE(aTHX_ "Offset outside string");
}
offset += blen_chars;
- } else if (offset >= (IV)blen_chars) {
+ } else if (offset > (IV)blen_chars) {
Safefree(tmpbuf);
DIE(aTHX_ "Offset outside string");
}
ok(!-s $outfile);
# should not be able to write from after the buffer
-eval { syswrite(O, $x, 1, 3) };
+eval { syswrite(O, $x, 1, 4) };
like($@, qr/^Offset outside string /);
# $x still intact
is($x, 'abc');
+# but it should be ok to write from the end of the buffer
+syswrite(O, $x, 0, 3);
+syswrite(O, $x, 1, 3);
+
# $outfile still intact
if ($reopen) { # must close file to update EOF marker for stat
close O; open(O, ">>$outfile") || die "sysio.t: cannot write $outfile: $!";
ok(!-s $outfile);
# [perl #67912] syswrite prints garbage if called with empty scalar and non-zero offset
-eval { my $buf = ''; syswrite(O, $buf, 1, 0) };
+eval { my $buf = ''; syswrite(O, $buf, 1, 1) };
like($@, qr/^Offset outside string /);
# $x still intact
}
ok(!-s $outfile);
-eval { my $buf = 'x'; syswrite(O, $buf, 1, 1) };
+eval { my $buf = 'x'; syswrite(O, $buf, 1, 2) };
like($@, qr/^Offset outside string /);
# $x still intact