summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTony Cook <tony@develop-help.com>2018-08-08 14:21:33 +1000
committerSteve Hay <steve.m.hay@googlemail.com>2019-04-02 12:18:25 +0100
commitf6f437abe6ca6dec887099a763a10d5dced15b71 (patch)
tree031aaa82fa293c45edc2ab6b43f90fe43011cf49
parent9f6706159c74bc4e54862ad6669ff9fe7f6f4edc (diff)
downloadperl-f6f437abe6ca6dec887099a763a10d5dced15b71.tar.gz
(perl #133422) handle Off_t smaller than size_t
(cherry picked from commit b9965e1496efe3cb6116e74d50aa83152c70e877)
-rw-r--r--ext/PerlIO-scalar/scalar.pm2
-rw-r--r--ext/PerlIO-scalar/scalar.xs11
2 files changed, 11 insertions, 2 deletions
diff --git a/ext/PerlIO-scalar/scalar.pm b/ext/PerlIO-scalar/scalar.pm
index 61b62ea3a2..6f4fa176be 100644
--- a/ext/PerlIO-scalar/scalar.pm
+++ b/ext/PerlIO-scalar/scalar.pm
@@ -1,5 +1,5 @@
package PerlIO::scalar;
-our $VERSION = '0.29';
+our $VERSION = '0.30';
require XSLoader;
XSLoader::load();
1;
diff --git a/ext/PerlIO-scalar/scalar.xs b/ext/PerlIO-scalar/scalar.xs
index 10a4185899..e717736fab 100644
--- a/ext/PerlIO-scalar/scalar.xs
+++ b/ext/PerlIO-scalar/scalar.xs
@@ -185,11 +185,20 @@ PerlIOScalar_read(pTHX_ PerlIO *f, void *vbuf, Size_t count)
/* I assume that Off_t is at least as large as len (which
* seems safe) and that the size of the buffer in our SV is
* always less than half the size of the address space
+ *
+ * Which turns out not to be the case on 64-bit Windows, since
+ * a build with USE_LARGE_FILES=undef defines Off_t as long,
+ * which is 32-bits on 64-bit Windows. This doesn't appear to
+ * be the case on other 64-bit platforms.
*/
- STATIC_ASSERT_STMT(sizeof(Off_t) >= sizeof(len));
+#if Off_t_size >= Size_t_size
assert(len < ((~(STRLEN)0) >> 1));
if ((Off_t)len <= s->posn)
return 0;
+#else
+ if (len <= (STRLEN)s->posn)
+ return 0;
+#endif
got = len - (STRLEN)(s->posn);
if ((STRLEN)got > (STRLEN)count)
got = (STRLEN)count;