X-Git-Url: http://erislabs.net/gitweb/?a=blobdiff_plain;f=lib%2Fwcswidth-impl.h;h=b71f99769cc6a07a8d8125d370e8df4942117980;hb=cd56634a4a8179fd5a4419fbb3e27211b042ab1c;hp=dc1a60c53213e8b09834655b9991007ce1319694;hpb=cbe8a0a3fe09047b99e5c0cfb67f45634d036487;p=gnulib.git diff --git a/lib/wcswidth-impl.h b/lib/wcswidth-impl.h index dc1a60c53..b71f99769 100644 --- a/lib/wcswidth-impl.h +++ b/lib/wcswidth-impl.h @@ -1,5 +1,5 @@ /* Determine number of screen columns needed for a size-bounded wide string. - Copyright (C) 1999, 2011 Free Software Foundation, Inc. + Copyright (C) 1999, 2011-2014 Free Software Foundation, Inc. Written by Bruno Haible , 1999. This program is free software: you can redistribute it and/or modify @@ -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; }