Skip to content

Commit 837cb43

Browse files
committed
ffprobe: Fix null pointer dereference with color primaries
Found-by: AD-lab of venustech Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
1 parent 2b44dcb commit 837cb43

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

Diff for: ffprobe.c

+12-8
Original file line numberDiff line numberDiff line change
@@ -1925,6 +1925,16 @@ static void print_pkt_side_data(WriterContext *w,
19251925
writer_print_section_footer(w);
19261926
}
19271927

1928+
static void print_primaries(WriterContext *w, enum AVColorPrimaries color_primaries)
1929+
{
1930+
const char *val = av_color_primaries_name(color_primaries);
1931+
if (!val || color_primaries == AVCOL_PRI_UNSPECIFIED) {
1932+
print_str_opt("color_primaries", "unknown");
1933+
} else {
1934+
print_str("color_primaries", val);
1935+
}
1936+
}
1937+
19281938
static void clear_log(int need_lock)
19291939
{
19301940
int i;
@@ -2116,10 +2126,7 @@ static void show_frame(WriterContext *w, AVFrame *frame, AVStream *stream,
21162126
else
21172127
print_str_opt("color_space", av_color_space_name(frame->colorspace));
21182128

2119-
if (frame->color_primaries != AVCOL_PRI_UNSPECIFIED)
2120-
print_str("color_primaries", av_color_primaries_name(frame->color_primaries));
2121-
else
2122-
print_str_opt("color_primaries", av_color_primaries_name(frame->color_primaries));
2129+
print_primaries(w, frame->color_primaries);
21232130

21242131
if (frame->color_trc != AVCOL_TRC_UNSPECIFIED)
21252132
print_str("color_transfer", av_color_transfer_name(frame->color_trc));
@@ -2516,10 +2523,7 @@ static int show_stream(WriterContext *w, AVFormatContext *fmt_ctx, int stream_id
25162523
else
25172524
print_str_opt("color_transfer", av_color_transfer_name(par->color_trc));
25182525

2519-
if (par->color_primaries != AVCOL_PRI_UNSPECIFIED)
2520-
print_str("color_primaries", av_color_primaries_name(par->color_primaries));
2521-
else
2522-
print_str_opt("color_primaries", av_color_primaries_name(par->color_primaries));
2526+
print_primaries(w, par->color_primaries);
25232527

25242528
if (par->chroma_location != AVCHROMA_LOC_UNSPECIFIED)
25252529
print_str("chroma_location", av_chroma_location_name(par->chroma_location));

0 commit comments

Comments
 (0)