summaryrefslogtreecommitdiffstats
path: root/libavcodec/fitsdec.c
diff options
context:
space:
mode:
authorJames Almer <jamrial@gmail.com>2019-09-28 23:11:06 -0300
committerJames Almer <jamrial@gmail.com>2019-09-29 12:44:43 -0300
commite3f0ecfc57889de0e0a359ec30b77851d53cea87 (patch)
tree7acc262e909d0be378bba286ef2ef4ea7768ce85 /libavcodec/fitsdec.c
parent9fdc2c7bc45b062457f3d58578e3a02dd945c9c4 (diff)
downloadffmpeg-streaming-e3f0ecfc57889de0e0a359ec30b77851d53cea87.zip
ffmpeg-streaming-e3f0ecfc57889de0e0a359ec30b77851d53cea87.tar.gz
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 cfa193779103c97bbfc28273a0ab12c114b6786d. Reviewed-by: Michael Niedermayer <michael@niedermayer.cc> Signed-off-by: James Almer <jamrial@gmail.com>
Diffstat (limited to 'libavcodec/fitsdec.c')
-rw-r--r--libavcodec/fitsdec.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/libavcodec/fitsdec.c b/libavcodec/fitsdec.c
index 88b841a..a20b8fa 100644
--- a/libavcodec/fitsdec.c
+++ b/libavcodec/fitsdec.c
@@ -195,7 +195,6 @@ static int fits_decode_frame(AVCodecContext *avctx, void *data, int *got_frame,
uint8_t *dst8;
uint16_t *dst16;
uint64_t t;
- double scale;
FITSHeader header;
FITSContext * fitsctx = avctx->priv_data;
@@ -205,12 +204,6 @@ static int fits_decode_frame(AVCodecContext *avctx, void *data, int *got_frame,
if (ret < 0)
return ret;
- scale = header.data_max - header.data_min;
- if (scale <= 0 || !isfinite(scale)) {
- scale = 1;
- }
- scale = 1/scale;
-
if (header.rgb) {
if (header.bitpix == 8) {
if (header.naxisn[2] == 3) {
@@ -271,6 +264,13 @@ static int fits_decode_frame(AVCodecContext *avctx, void *data, int *got_frame,
CASE_RGB(16, dst16, uint16_t, AV_RB16);
}
} else {
+ double scale = header.data_max - header.data_min;
+
+ if (scale <= 0 || !isfinite(scale)) {
+ scale = 1;
+ }
+ scale = 1/scale;
+
switch (header.bitpix) {
#define CASE_GRAY(cas, dst, type, t, rd) \
case cas: \
OpenPOWER on IntegriCloud