Changeset 4536


Ignore:
Timestamp:
Jun 18, 2013 4:08:08 AM (7 years ago)
Author:
ming
Message:

Closed #1678: Proper error handling in WAV writer

File:
1 edited

Legend:

Unmodified
Added
Removed
  • pjproject/trunk/pjmedia/src/pjmedia/wav_writer.c

    r3664 r4536  
    399399    /* Get file size. */ 
    400400    status = pj_file_getpos(fport->fd, &file_size); 
    401     PJ_ASSERT_RETURN(status == PJ_SUCCESS, status); 
     401    if (status != PJ_SUCCESS) { 
     402        pj_file_close(fport->fd); 
     403        return status; 
     404    } 
    402405 
    403406    /* Calculate wave fields */ 
     
    412415    /* Seek to the file_len field. */ 
    413416    status = pj_file_setpos(fport->fd, FILE_LEN_POS, PJ_SEEK_SET); 
    414     PJ_ASSERT_RETURN(status == PJ_SUCCESS, status); 
     417    if (status != PJ_SUCCESS) { 
     418        pj_file_close(fport->fd); 
     419        return status; 
     420    } 
    415421 
    416422    /* Write file_len */ 
    417423    bytes = sizeof(wave_file_len); 
    418424    status = pj_file_write(fport->fd, &wave_file_len, &bytes); 
    419     PJ_ASSERT_RETURN(status == PJ_SUCCESS, status); 
     425    if (status != PJ_SUCCESS) { 
     426        pj_file_close(fport->fd); 
     427        return status; 
     428    } 
    420429 
    421430    /* Write samples_len in FACT chunk */ 
     
    431440        /* Seek to samples_len field. */ 
    432441        status = pj_file_setpos(fport->fd, SAMPLES_LEN_POS, PJ_SEEK_SET); 
    433         PJ_ASSERT_RETURN(status == PJ_SUCCESS, status); 
     442        if (status != PJ_SUCCESS) { 
     443            pj_file_close(fport->fd); 
     444            return status; 
     445        } 
    434446 
    435447        /* Write samples_len */ 
    436448        bytes = sizeof(wav_samples_len); 
    437449        status = pj_file_write(fport->fd, &wav_samples_len, &bytes); 
    438         PJ_ASSERT_RETURN(status == PJ_SUCCESS, status); 
     450        if (status != PJ_SUCCESS) { 
     451            pj_file_close(fport->fd); 
     452            return status; 
     453        } 
    439454    } 
    440455 
    441456    /* Seek to data_len field. */ 
    442457    status = pj_file_setpos(fport->fd, data_len_pos, PJ_SEEK_SET); 
    443     PJ_ASSERT_RETURN(status == PJ_SUCCESS, status); 
     458    if (status != PJ_SUCCESS) { 
     459        pj_file_close(fport->fd); 
     460        return status; 
     461    } 
    444462 
    445463    /* Write file_len */ 
    446464    bytes = sizeof(wave_data_len); 
    447465    status = pj_file_write(fport->fd, &wave_data_len, &bytes); 
    448     PJ_ASSERT_RETURN(status == PJ_SUCCESS, status); 
     466    if (status != PJ_SUCCESS) { 
     467        pj_file_close(fport->fd); 
     468        return status; 
     469    } 
    449470 
    450471    /* Close file */ 
    451472    status = pj_file_close(fport->fd); 
    452     PJ_ASSERT_RETURN(status == PJ_SUCCESS, status); 
     473    if (status != PJ_SUCCESS) 
     474        return status; 
    453475 
    454476    /* Done. */ 
Note: See TracChangeset for help on using the changeset viewer.