aboutsummaryrefslogtreecommitdiffstats
path: root/libavutil/parseutils.c
diff options
context:
space:
mode:
authorReimar Döffinger <Reimar.Doeffinger@gmx.de>2012-04-24 20:18:57 +0200
committerReimar Döffinger <Reimar.Doeffinger@gmx.de>2012-04-24 21:28:24 +0200
commit2b336df3cb9d9bcc12c4b398ea1dbdfe224d152e (patch)
treec59cb13dd1dcca05294b6ad8fbeadc15e30239c9 /libavutil/parseutils.c
parent44bd2f90a973960db5e5c74bf21110de8434a10f (diff)
downloadffmpeg-2b336df3cb9d9bcc12c4b398ea1dbdfe224d152e.tar.gz
parseutils: reliably detect out-of-range alpha.
This should fix the FATE test on ARM (not tested), but it should also detect alpha values like 2^128 reliably as invalid which would be another out-of-range case with implementation-dependant behaviour. Signed-off-by: Reimar Döffinger <Reimar.Doeffinger@gmx.de>
Diffstat (limited to 'libavutil/parseutils.c')
-rw-r--r--libavutil/parseutils.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/libavutil/parseutils.c b/libavutil/parseutils.c
index 064d490a04..037c4fb9f6 100644
--- a/libavutil/parseutils.c
+++ b/libavutil/parseutils.c
@@ -394,7 +394,11 @@ int av_parse_color(uint8_t *rgba_color, const char *color_string, int slen,
if (!strncmp(alpha_string, "0x", 2)) {
alpha = strtoul(alpha_string, &tail, 16);
} else {
- alpha = 255 * strtod(alpha_string, &tail);
+ double norm_alpha = strtod(alpha_string, &tail);
+ if (norm_alpha < 0.0 || norm_alpha > 1.0)
+ alpha = 256;
+ else
+ alpha = 255 * norm_alpha;
}
if (tail == alpha_string || *tail || alpha > 255) {