summaryrefslogtreecommitdiff
path: root/tools/crypto_bench.c
diff options
context:
space:
mode:
authorJun Zhao <barryjzhao@tencent.com>2019-05-09 01:16:27 +0800
committerJun Zhao <barryjzhao@tencent.com>2019-05-09 16:59:55 +0800
commit153a6a67a93af0f0bd00d76670e59e741c9a13c7 (patch)
tree5ab7701ef29108a4a867d9a72a0741b679eccca6 /tools/crypto_bench.c
parent181031906e4984c1c539dc84d21386a4397e257e (diff)
downloadffmpeg-153a6a67a93af0f0bd00d76670e59e741c9a13c7.tar.gz
tools/crypto_bench: check malloc fail before using it
Need to check malloc fail before using it, so adjust the location in the code. Reviewed-by: Nicolas George <nicolas.george@normalesup.org> Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
Diffstat (limited to 'tools/crypto_bench.c')
-rw-r--r--tools/crypto_bench.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/tools/crypto_bench.c b/tools/crypto_bench.c
index aca8bbb1a8..ac9fcc465e 100644
--- a/tools/crypto_bench.c
+++ b/tools/crypto_bench.c
@@ -665,8 +665,8 @@ struct hash_impl implementations[] = {
int main(int argc, char **argv)
{
- uint8_t *input = av_malloc(MAX_INPUT_SIZE * 2);
- uint8_t *output = input + MAX_INPUT_SIZE;
+ uint8_t *input;
+ uint8_t *output;
unsigned i, impl, size;
int opt;
@@ -702,12 +702,14 @@ int main(int argc, char **argv)
exit(opt != 'h');
}
}
-
+ input = av_malloc(MAX_INPUT_SIZE * 2);
if (!input)
fatal_error("out of memory");
for (i = 0; i < MAX_INPUT_SIZE; i += 4)
AV_WB32(input + i, i);
+ output = input + MAX_INPUT_SIZE;
+
size = MAX_INPUT_SIZE;
for (impl = 0; impl < FF_ARRAY_ELEMS(implementations); impl++)
run_implementation(input, output, &implementations[impl], size);