diff options
author | wm4 <wm4@nowhere> | 2014-07-01 23:10:38 +0200 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2014-07-01 23:11:08 +0200 |
commit | 9a210ca2d50e02bf045866bbb2f44a33a3c48cd9 (patch) | |
tree | 9f685c66c9d3b2e968416c7f60d30ea56ab1f9bb /video/out/vo_opengl_old.c | |
parent | 0208ad4f3b4d2331b8242bb6fb12a9a4475ccae6 (diff) | |
download | mpv-9a210ca2d50e02bf045866bbb2f44a33a3c48cd9.tar.bz2 mpv-9a210ca2d50e02bf045866bbb2f44a33a3c48cd9.tar.xz |
Audit and replace all ctype.h uses
Something like "char *s = ...; isdigit(s[0]);" triggers undefined
behavior, because char can be signed, and thus s[0] can be a negative
value. The is*() functions require unsigned char _or_ EOF. EOF is a
special value outside of unsigned char range, thus the argument to the
is*() functions can't be a char.
This undefined behavior can actually trigger crashes if the
implementation of these functions e.g. uses lookup tables, which are
then indexed with out-of-range values.
Replace all <ctype.h> uses with our own custom mp_is*() functions added
with misc/ctype.h. As a bonus, these functions are locale-independent.
(Although currently, we _require_ C locale for other reasons.)
Diffstat (limited to 'video/out/vo_opengl_old.c')
-rw-r--r-- | video/out/vo_opengl_old.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/video/out/vo_opengl_old.c b/video/out/vo_opengl_old.c index d9c7e8baed..87ba48068a 100644 --- a/video/out/vo_opengl_old.c +++ b/video/out/vo_opengl_old.c @@ -28,12 +28,12 @@ #include <string.h> #include <math.h> #include <stdbool.h> -#include <ctype.h> #include <assert.h> #include "config.h" #include "talloc.h" #include "common/msg.h" +#include "misc/ctype.h" #include "options/m_option.h" #include "vo.h" #include "video/vfcap.h" @@ -538,7 +538,7 @@ static void replace_var_str(char **text, const char *name, const char *replace) nextvar += namelen; // try not to replace prefixes of other vars (e.g. $foo vs. $foo_bar) char term = nextvar[0]; - if (isalnum(term) || term == '_') + if (mp_isalnum(term) || term == '_') continue; int prelength = until - *text; int postlength = nextvar - *text; |