Changeset 1034

Show
Ignore:
Timestamp:
03/20/09 13:58:28 (1 year ago)
Author:
gbooker
Message:

sanity check on reading packet info. Crasher fix.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/Subtitles/SubImport.mm

    r1020 r1034  
    717717} 
    718718 
    719 static void ReadPacketTimes(uint8_t *packet, uint32_t length, uint16_t *startTime, uint16_t *endTime, uint8_t *forced) { 
     719static Boolean ReadPacketTimes(uint8_t *packet, uint32_t length, uint16_t *startTime, uint16_t *endTime, uint8_t *forced) { 
    720720        // to set whether the key sequences 0x01 - 0x02 have been seen 
    721721        Boolean loop = TRUE; 
     
    726726        while(loop) 
    727727        {        
     728                if(controlOffset > length) 
     729                        return NO; 
    728730                uint8_t *controlSeq = packet + controlOffset; 
    729731                int32_t i = 4; 
     
    779781                                default: 
    780782                                        Codecprintf(NULL, " !! Unknown control sequence 0x%02x  aborting (offset %x)\n", controlSeq[i], i); 
    781                                         loop = FALSE
     783                                        return NO
    782784                                        break; 
    783785                        } 
     
    789791                } 
    790792        } 
     793        return YES; 
    791794} 
    792795 
     
    838841                uint16_t startTimestamp, endTimestamp; 
    839842                uint8_t forced; 
    840                 ReadPacketTimes(extracted, extractedSize, &startTimestamp, &endTimestamp, &forced); 
     843                if(!ReadPacketTimes(extracted, extractedSize, &startTimestamp, &endTimestamp, &forced)) 
     844                        continue; 
    841845                if(onlyForced && !forced) 
    842846                        continue;