Commit e3f0ecfc authored by James Almer's avatar James Almer

avcodec/fitsdec: fix use of uninitialised values

header.data_max and header.data_min are not necessarely set on all decoding scenarios.

Fixes a Valgrind reported regression since cfa19377.
Reviewed-by: 's avatarMichael Niedermayer <michael@niedermayer.cc>
Signed-off-by: 's avatarJames Almer <jamrial@gmail.com>
parent 9fdc2c7b
...@@ -195,7 +195,6 @@ static int fits_decode_frame(AVCodecContext *avctx, void *data, int *got_frame, ...@@ -195,7 +195,6 @@ static int fits_decode_frame(AVCodecContext *avctx, void *data, int *got_frame,
uint8_t *dst8; uint8_t *dst8;
uint16_t *dst16; uint16_t *dst16;
uint64_t t; uint64_t t;
double scale;
FITSHeader header; FITSHeader header;
FITSContext * fitsctx = avctx->priv_data; FITSContext * fitsctx = avctx->priv_data;
...@@ -205,12 +204,6 @@ static int fits_decode_frame(AVCodecContext *avctx, void *data, int *got_frame, ...@@ -205,12 +204,6 @@ static int fits_decode_frame(AVCodecContext *avctx, void *data, int *got_frame,
if (ret < 0) if (ret < 0)
return ret; return ret;
scale = header.data_max - header.data_min;
if (scale <= 0 || !isfinite(scale)) {
scale = 1;
}
scale = 1/scale;
if (header.rgb) { if (header.rgb) {
if (header.bitpix == 8) { if (header.bitpix == 8) {
if (header.naxisn[2] == 3) { if (header.naxisn[2] == 3) {
...@@ -271,6 +264,13 @@ static int fits_decode_frame(AVCodecContext *avctx, void *data, int *got_frame, ...@@ -271,6 +264,13 @@ static int fits_decode_frame(AVCodecContext *avctx, void *data, int *got_frame,
CASE_RGB(16, dst16, uint16_t, AV_RB16); CASE_RGB(16, dst16, uint16_t, AV_RB16);
} }
} else { } else {
double scale = header.data_max - header.data_min;
if (scale <= 0 || !isfinite(scale)) {
scale = 1;
}
scale = 1/scale;
switch (header.bitpix) { switch (header.bitpix) {
#define CASE_GRAY(cas, dst, type, t, rd) \ #define CASE_GRAY(cas, dst, type, t, rd) \
case cas: \ case cas: \
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment