aboutsummaryrefslogtreecommitdiffstats
path: root/ext/iconv
diff options
context:
space:
mode:
Diffstat (limited to 'ext/iconv')
-rw-r--r--ext/iconv/extconf.rb1
-rw-r--r--ext/iconv/iconv.c6
2 files changed, 6 insertions, 1 deletions
diff --git a/ext/iconv/extconf.rb b/ext/iconv/extconf.rb
index 9632bf4db9..c4a57c80d6 100644
--- a/ext/iconv/extconf.rb
+++ b/ext/iconv/extconf.rb
@@ -7,6 +7,7 @@ conf = with_config("config-charset", enable_config("config-charset", conf))
if have_func("iconv", "iconv.h") or
have_library("iconv", "iconv", "iconv.h")
+ check_signedness("size_t")
if checking_for("const of iconv() 2nd argument") do
create_tmpsrc(cpp_include("iconv.h") + "---> iconv(cd,0,0,0,0) <---")
src = xpopen(cpp_command("")) {|f|f.read}
diff --git a/ext/iconv/iconv.c b/ext/iconv/iconv.c
index c4c6fd8124..cf77ee3e2c 100644
--- a/ext/iconv/iconv.c
+++ b/ext/iconv/iconv.c
@@ -464,7 +464,11 @@ iconv_convert(iconv_t cd, VALUE str, long start, long length, int toidx, struct
errmsg[0] = 0;
error = iconv_try(cd, &inptr, &inlen, &outptr, &outlen);
- if (0 <= outlen && outlen <= sizeof(buffer)) {
+ if (
+#if SIGNEDNESS_OF_SIZE_T < 0
+ 0 <= outlen &&
+#endif
+ outlen <= sizeof(buffer)) {
outlen = sizeof(buffer) - outlen;
if (NIL_P(error) || /* something converted */
outlen > (size_t)(inptr - tmpstart) || /* input can't contain output */