Ticket #62: bugfix_parcat.patch

File bugfix_parcat.patch, 891 bytes (added by tpoirier, 6 years ago)
  • App/Parcat/parcat.cpp

     
    138138  *nal_end = 0;
    139139
    140140  i = 0;
    141   while (   //( next_bits( 24 ) != 0x000001 && next_bits( 32 ) != 0x00000001 )
     141  while (i + 3 < size &&  //( next_bits( 24 ) != 0x000001 && next_bits( 32 ) != 0x00000001 )
    142142    (buf[i] != 0 || buf[i+1] != 0 || buf[i+2] != 0x01) &&
    143143    (buf[i] != 0 || buf[i+1] != 0 || buf[i+2] != 0 || buf[i+3] != 0x01)
    144144    )
    145145  {
    146146    i++; // skip leading zero
    147     if (i+4 >= size) { return 0; } // did not find nal start
     147    if (i+4 >= size) { printf("Unexpected EOF \n"); exit(-1); } // did not find nal start
    148148  }
    149149
     150  if (i + 3 >= size) { return 0; }
     151
    150152  if  (buf[i] != 0 || buf[i+1] != 0 || buf[i+2] != 0x01) // ( next_bits( 24 ) != 0x000001 )
    151153  {
    152154    i++;