aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorhighgod0401 <highgod0401@gmail.com>2013-04-04 20:11:51 +0800
committerMichael Niedermayer <michaelni@gmx.at>2013-04-04 19:26:16 +0200
commit322428c851980396485d4c6bb4cfe79db43467f8 (patch)
tree9b5191316083507c10c683965847c01a7e860cef
parent39406ea321ce8f4c52944fa799f90ab984fed4eb (diff)
downloadffmpeg-322428c851980396485d4c6bb4cfe79db43467f8.tar.gz
avutil/opencl: check strtol for failure
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
-rw-r--r--libavutil/opencl.c15
1 files changed, 13 insertions, 2 deletions
diff --git a/libavutil/opencl.c b/libavutil/opencl.c
index e618829a70..0bf7a8294d 100644
--- a/libavutil/opencl.c
+++ b/libavutil/opencl.c
@@ -518,6 +518,7 @@ int av_opencl_init(AVDictionary *options, AVOpenCLExternalEnv *ext_opencl_env)
AVDictionaryEntry *opt_build_entry;
AVDictionaryEntry *opt_platform_entry;
AVDictionaryEntry *opt_device_entry;
+ char *pos;
LOCK_OPENCL
if (!gpu_env.init_count) {
opt_platform_entry = av_dict_get(options, "platform_idx", NULL, 0);
@@ -526,10 +527,20 @@ int av_opencl_init(AVDictionary *options, AVOpenCLExternalEnv *ext_opencl_env)
gpu_env.usr_spec_dev_info.platform_idx = -1;
gpu_env.usr_spec_dev_info.dev_idx = -1;
if (opt_platform_entry) {
- gpu_env.usr_spec_dev_info.platform_idx = strtol(opt_platform_entry->value, NULL, 10);
+ gpu_env.usr_spec_dev_info.platform_idx = strtol(opt_platform_entry->value, &pos, 10);
+ if (pos == opt_platform_entry->value) {
+ av_log(&openclutils, AV_LOG_ERROR, "Platform index should be a number\n");
+ ret = AVERROR(EINVAL);
+ goto end;
+ }
}
if (opt_device_entry) {
- gpu_env.usr_spec_dev_info.dev_idx = strtol(opt_device_entry->value, NULL, 10);
+ gpu_env.usr_spec_dev_info.dev_idx = strtol(opt_device_entry->value, &pos, 10);
+ if (pos == opt_platform_entry->value) {
+ av_log(&openclutils, AV_LOG_ERROR, "Device index should be a number\n");
+ ret = AVERROR(EINVAL);
+ goto end;
+ }
}
ret = init_opencl_env(&gpu_env, ext_opencl_env);
if (ret < 0)