mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2024-12-23 12:43:46 +02:00
tests/tiny_ssim: check dimensions
Fix integer overflow Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
This commit is contained in:
parent
78d3453c4a
commit
a69e16a97e
@ -29,6 +29,7 @@
|
|||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
|
#include <limits.h>
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
@ -195,7 +196,13 @@ int main(int argc, char* argv[])
|
|||||||
f[0] = fopen(argv[1], "rb");
|
f[0] = fopen(argv[1], "rb");
|
||||||
f[1] = fopen(argv[2], "rb");
|
f[1] = fopen(argv[2], "rb");
|
||||||
sscanf(argv[3], "%dx%d", &w, &h);
|
sscanf(argv[3], "%dx%d", &w, &h);
|
||||||
frame_size = w*h*3/2;
|
|
||||||
|
if (w<=0 || h<=0 || w*(int64_t)h >= INT_MAX/3 || 2LL*w+12 >= INT_MAX / sizeof(*temp)) {
|
||||||
|
fprintf(stderr, "Dimensions are too large\n");
|
||||||
|
return -2;
|
||||||
|
}
|
||||||
|
|
||||||
|
frame_size = w*h*3LL/2;
|
||||||
for( i=0; i<2; i++ )
|
for( i=0; i<2; i++ )
|
||||||
{
|
{
|
||||||
buf[i] = malloc(frame_size);
|
buf[i] = malloc(frame_size);
|
||||||
|
Loading…
Reference in New Issue
Block a user