ffprobe: fix consistency checks in parse_read_intervals()

Move array size assert after the count increment, and avoid strchr() NULL
dereference on p.

Should fix FFmpeg coverity issue #1108581.
pull/39/head
Stefano Sabatini 11 years ago
parent 09ba986cae
commit ddaf33f5bb
  1. 8
      ffprobe.c

@ -2460,8 +2460,11 @@ static int parse_read_intervals(const char *intervals_spec)
/* parse intervals */ /* parse intervals */
p = spec; p = spec;
for (i = 0; i < n; i++) { for (i = 0; p; i++) {
char *next = strchr(p, ','); char *next;
av_assert0(i < read_intervals_nb);
next = strchr(p, ',');
if (next) if (next)
*next++ = 0; *next++ = 0;
@ -2475,7 +2478,6 @@ static int parse_read_intervals(const char *intervals_spec)
av_log(NULL, AV_LOG_VERBOSE, "Parsed log interval "); av_log(NULL, AV_LOG_VERBOSE, "Parsed log interval ");
log_read_interval(&read_intervals[i], NULL, AV_LOG_VERBOSE); log_read_interval(&read_intervals[i], NULL, AV_LOG_VERBOSE);
p = next; p = next;
av_assert0(i <= read_intervals_nb);
} }
av_assert0(i == read_intervals_nb); av_assert0(i == read_intervals_nb);

Loading…
Cancel
Save