X-Git-Url: http://erislabs.net/gitweb/?a=blobdiff_plain;f=lib%2Fwcswidth-impl.h;h=865390c5e9ee2b760c64d2da7351b54854bc8ad3;hb=b65bfcd7ba0be84de3d96f22103103f21679a721;hp=dc1a60c53213e8b09834655b9991007ce1319694;hpb=cbe8a0a3fe09047b99e5c0cfb67f45634d036487;p=gnulib.git diff --git a/lib/wcswidth-impl.h b/lib/wcswidth-impl.h index dc1a60c53..865390c5e 100644 --- a/lib/wcswidth-impl.h +++ b/lib/wcswidth-impl.h @@ -28,6 +28,8 @@ wcswidth (const wchar_t *s, size_t n) int width = wcwidth (c); if (width < 0) goto found_nonprinting; + if (width > INT_MAX - count) + goto overflow; count += width; } } @@ -35,4 +37,7 @@ wcswidth (const wchar_t *s, size_t n) found_nonprinting: return -1; + + overflow: + return INT_MAX; }