Skip to content

Commit 34cb040

Browse files
fix null pointer dereferences in intra channel and long term prediction (#234)
* fix null pointer dereference in intra channel prediction Ensure "pred_stat" is not null in reconstruct_channel_pair(), similar to the check in reconstruct_single_channel(). * fix null pointer dereference in long term prediction Like ic_prediction(), lt_prediction() expects a "pred_stat" parameter which is not null. Add checks to ensure that and add a new error message.
1 parent 82fa08e commit 34cb040

3 files changed

Lines changed: 14 additions & 5 deletions

File tree

libfaad/error.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,6 @@ char *err_msg[] = {
6565
"No standard extension payload allowed in DRM",
6666
"PCE shall be the first element in a frame",
6767
"Bitstream value not allowed by specification",
68-
"MAIN prediction not initialised"
68+
"MAIN prediction not initialised",
69+
"Long term prediction not initialised"
6970
};
70-

libfaad/error.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
extern "C" {
3636
#endif
3737

38-
#define NUM_ERROR_MESSAGES 34
38+
#define NUM_ERROR_MESSAGES 35
3939
extern char *err_msg[];
4040

4141
#ifdef __cplusplus

libfaad/specrec.c

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1006,8 +1006,8 @@ uint8_t reconstruct_single_channel(NeAACDecStruct *hDecoder, ic_stream *ics,
10061006
/* MAIN object type prediction */
10071007
if (hDecoder->object_type == MAIN)
10081008
{
1009-
if (!hDecoder->pred_stat[sce->channel])
1010-
return 33;
1009+
if (!hDecoder->pred_stat[sce->channel])
1010+
return 33;
10111011

10121012
/* intra channel prediction */
10131013
ic_prediction(ics, spec_coef, hDecoder->pred_stat[sce->channel], hDecoder->frameLength,
@@ -1036,6 +1036,9 @@ uint8_t reconstruct_single_channel(NeAACDecStruct *hDecoder, ic_stream *ics,
10361036
}
10371037
#endif
10381038

1039+
if (!hDecoder->lt_pred_stat[sce->channel])
1040+
return 34;
1041+
10391042
/* long term prediction */
10401043
lt_prediction(ics, &(ics->ltp), spec_coef, hDecoder->lt_pred_stat[sce->channel], hDecoder->fb,
10411044
ics->window_shape, hDecoder->window_shape_prev[sce->channel],
@@ -1240,6 +1243,9 @@ uint8_t reconstruct_channel_pair(NeAACDecStruct *hDecoder, ic_stream *ics1, ic_s
12401243
/* MAIN object type prediction */
12411244
if (hDecoder->object_type == MAIN)
12421245
{
1246+
if (!hDecoder->pred_stat[cpe->channel] || !hDecoder->pred_stat[cpe->paired_channel])
1247+
return 33;
1248+
12431249
/* intra channel prediction */
12441250
ic_prediction(ics1, spec_coef1, hDecoder->pred_stat[cpe->channel], hDecoder->frameLength,
12451251
hDecoder->sf_index);
@@ -1278,6 +1284,9 @@ uint8_t reconstruct_channel_pair(NeAACDecStruct *hDecoder, ic_stream *ics1, ic_s
12781284
}
12791285
#endif
12801286

1287+
if (!hDecoder->lt_pred_stat[cpe->channel] || !hDecoder->lt_pred_stat[cpe->paired_channel])
1288+
return 34;
1289+
12811290
/* long term prediction */
12821291
lt_prediction(ics1, ltp1, spec_coef1, hDecoder->lt_pred_stat[cpe->channel], hDecoder->fb,
12831292
ics1->window_shape, hDecoder->window_shape_prev[cpe->channel],

0 commit comments

Comments
 (0)