Changeset 153


Ignore:
Timestamp:
12/07/06 20:35:14 (18 years ago)
Author:
zorg
Message:

Fix broken stream initialization on non-mpc files

File:
1 edited

Legend:

Unmodified
Added
Removed
  • libmpcdec/trunk/src/streaminfo.c

    r37 r153  
    216216    si->total_file_length = r->get_size(r->data);
    217217    si->tag_offset = si->total_file_length;
    218     if (memcmp(HeaderData, "MP+", 3) == 0) {
     218   
     219    if (memcmp(HeaderData, "MP+", 3)) return ERROR_CODE_INVALIDSV;
    219220#ifndef MPC_LITTLE_ENDIAN
     221    {
    220222        mpc_uint32_t ptr;
    221223        for (ptr = 0; ptr < 8; ptr++) {
    222224            HeaderData[ptr] = mpc_swap32(HeaderData[ptr]);
    223225        }
     226    }
    224227#endif
    225         si->stream_version = HeaderData[0] >> 24;
    226 
    227         // stream version 8
    228         if ((si->stream_version & 15) >= 8) {
    229             return ERROR_CODE_INVALIDSV;
    230         }
    231         // stream version 7
    232         else if ((si->stream_version & 15) == 7) {
    233             Error = streaminfo_read_header_sv7(si, HeaderData);
    234             if (Error != ERROR_CODE_OK) return Error;
    235         }
    236     } else {
     228   
     229    si->stream_version = HeaderData[0] >> 24;
     230
     231    // stream version 8
     232    if ((si->stream_version & 15) >= 8) {
     233        return ERROR_CODE_INVALIDSV;
     234    }
     235    // stream version 7
     236    else if ((si->stream_version & 15) == 7) {
     237        Error = streaminfo_read_header_sv7(si, HeaderData);
     238        if (Error != ERROR_CODE_OK) return Error;
     239    }
    237240#ifdef MPC_SUPPORT_SV456
     241    else {
    238242        // stream version 4-6
    239243        Error = streaminfo_read_header_sv6(si, HeaderData);
    240 #else
    241         return ERROR_CODE_INVALIDSV;
     244        if (Error != ERROR_CODE_OK) return Error;
     245    }
    242246#endif
    243     }
    244247
    245248    // estimation, exact value needs too much time
Note: See TracChangeset for help on using the changeset viewer.