Browse Source

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 cfa1937791.

Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: James Almer <jamrial@gmail.com>
(cherry picked from commit e3f0ecfc57)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
tags/n4.0.5
James Almer Michael Niedermayer 6 years ago
parent
commit
f0749555d7
1 changed files with 7 additions and 7 deletions
  1. +7
    -7
      libavcodec/fitsdec.c

+ 7
- 7
libavcodec/fitsdec.c View File

@@ -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: \


Loading…
Cancel
Save