swscale: check memory allocations
Bug-Id: CID 1257779
(cherry picked from commit 1dd797e3c9
)
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
This commit is contained in:

committed by
Michael Niedermayer

parent
61b31c6939
commit
3d5c48937b
@@ -782,9 +782,13 @@ av_cold int ff_yuv2rgb_c_init_tables(SwsContext *c, const int inv_table[4],
|
|||||||
|
|
||||||
av_free(c->yuvTable);
|
av_free(c->yuvTable);
|
||||||
|
|
||||||
|
#define ALLOC_YUV_TABLE(x) \
|
||||||
|
c->yuvTable = av_malloc(x); \
|
||||||
|
if (!c->yuvTable) \
|
||||||
|
return AVERROR(ENOMEM);
|
||||||
switch (bpp) {
|
switch (bpp) {
|
||||||
case 1:
|
case 1:
|
||||||
c->yuvTable = av_malloc(1024);
|
ALLOC_YUV_TABLE(1024);
|
||||||
y_table = c->yuvTable;
|
y_table = c->yuvTable;
|
||||||
yb = -(384 << 16) - oy;
|
yb = -(384 << 16) - oy;
|
||||||
for (i = 0; i < 1024 - 110; i++) {
|
for (i = 0; i < 1024 - 110; i++) {
|
||||||
@@ -799,7 +803,7 @@ av_cold int ff_yuv2rgb_c_init_tables(SwsContext *c, const int inv_table[4],
|
|||||||
rbase = isRgb ? 3 : 0;
|
rbase = isRgb ? 3 : 0;
|
||||||
gbase = 1;
|
gbase = 1;
|
||||||
bbase = isRgb ? 0 : 3;
|
bbase = isRgb ? 0 : 3;
|
||||||
c->yuvTable = av_malloc(1024 * 3);
|
ALLOC_YUV_TABLE(1024 * 3);
|
||||||
y_table = c->yuvTable;
|
y_table = c->yuvTable;
|
||||||
yb = -(384 << 16) - oy;
|
yb = -(384 << 16) - oy;
|
||||||
for (i = 0; i < 1024 - 110; i++) {
|
for (i = 0; i < 1024 - 110; i++) {
|
||||||
@@ -818,7 +822,7 @@ av_cold int ff_yuv2rgb_c_init_tables(SwsContext *c, const int inv_table[4],
|
|||||||
rbase = isRgb ? 5 : 0;
|
rbase = isRgb ? 5 : 0;
|
||||||
gbase = isRgb ? 2 : 3;
|
gbase = isRgb ? 2 : 3;
|
||||||
bbase = isRgb ? 0 : 6;
|
bbase = isRgb ? 0 : 6;
|
||||||
c->yuvTable = av_malloc(1024 * 3);
|
ALLOC_YUV_TABLE(1024 * 3);
|
||||||
y_table = c->yuvTable;
|
y_table = c->yuvTable;
|
||||||
yb = -(384 << 16) - oy;
|
yb = -(384 << 16) - oy;
|
||||||
for (i = 0; i < 1024 - 38; i++) {
|
for (i = 0; i < 1024 - 38; i++) {
|
||||||
@@ -837,7 +841,7 @@ av_cold int ff_yuv2rgb_c_init_tables(SwsContext *c, const int inv_table[4],
|
|||||||
rbase = isRgb ? 8 : 0;
|
rbase = isRgb ? 8 : 0;
|
||||||
gbase = 4;
|
gbase = 4;
|
||||||
bbase = isRgb ? 0 : 8;
|
bbase = isRgb ? 0 : 8;
|
||||||
c->yuvTable = av_malloc(1024 * 3 * 2);
|
ALLOC_YUV_TABLE(1024 * 3 * 2);
|
||||||
y_table16 = c->yuvTable;
|
y_table16 = c->yuvTable;
|
||||||
yb = -(384 << 16) - oy;
|
yb = -(384 << 16) - oy;
|
||||||
for (i = 0; i < 1024; i++) {
|
for (i = 0; i < 1024; i++) {
|
||||||
@@ -860,7 +864,7 @@ av_cold int ff_yuv2rgb_c_init_tables(SwsContext *c, const int inv_table[4],
|
|||||||
rbase = isRgb ? bpp - 5 : 0;
|
rbase = isRgb ? bpp - 5 : 0;
|
||||||
gbase = 5;
|
gbase = 5;
|
||||||
bbase = isRgb ? 0 : (bpp - 5);
|
bbase = isRgb ? 0 : (bpp - 5);
|
||||||
c->yuvTable = av_malloc(1024 * 3 * 2);
|
ALLOC_YUV_TABLE(1024 * 3 * 2);
|
||||||
y_table16 = c->yuvTable;
|
y_table16 = c->yuvTable;
|
||||||
yb = -(384 << 16) - oy;
|
yb = -(384 << 16) - oy;
|
||||||
for (i = 0; i < 1024; i++) {
|
for (i = 0; i < 1024; i++) {
|
||||||
@@ -880,7 +884,7 @@ av_cold int ff_yuv2rgb_c_init_tables(SwsContext *c, const int inv_table[4],
|
|||||||
break;
|
break;
|
||||||
case 24:
|
case 24:
|
||||||
case 48:
|
case 48:
|
||||||
c->yuvTable = av_malloc(1024);
|
ALLOC_YUV_TABLE(1024);
|
||||||
y_table = c->yuvTable;
|
y_table = c->yuvTable;
|
||||||
yb = -(384 << 16) - oy;
|
yb = -(384 << 16) - oy;
|
||||||
for (i = 0; i < 1024; i++) {
|
for (i = 0; i < 1024; i++) {
|
||||||
@@ -902,7 +906,7 @@ av_cold int ff_yuv2rgb_c_init_tables(SwsContext *c, const int inv_table[4],
|
|||||||
needAlpha = CONFIG_SWSCALE_ALPHA && isALPHA(c->srcFormat);
|
needAlpha = CONFIG_SWSCALE_ALPHA && isALPHA(c->srcFormat);
|
||||||
if (!needAlpha)
|
if (!needAlpha)
|
||||||
abase = (base + 24) & 31;
|
abase = (base + 24) & 31;
|
||||||
c->yuvTable = av_malloc(1024 * 3 * 4);
|
ALLOC_YUV_TABLE(1024 * 3 * 4);
|
||||||
y_table32 = c->yuvTable;
|
y_table32 = c->yuvTable;
|
||||||
yb = -(384 << 16) - oy;
|
yb = -(384 << 16) - oy;
|
||||||
for (i = 0; i < 1024; i++) {
|
for (i = 0; i < 1024; i++) {
|
||||||
|
Reference in New Issue
Block a user