Changeset 225300b59e7da3607721d9538775996097a30872

Show
Ignore:
Timestamp:
02/03/08 18:19:59 (9 months ago)
Author:
Jean-Paul Saman <jpsaman@videolan.org>
git-committer:
Jean-Paul Saman <jpsaman@videolan.org> 1204478399 +0100
git-parent:

[c13df5d1fcfd6381665f532b9f778ae17f55421a]

git-author:
Jean-Paul Saman <jpsaman@videolan.org> 1204468005 +0100
Message:

Don't leak memory when filling in p_stream->p_decoder_specific_info for subtitles. The p_stream->p_decoder_specific_info pointer was already allocated just before checking for VLC_FOURCC('s','u','b','t'). The fix moves the non-subtitles case to an else.

Signed-off-by: Jean-Paul Saman <jpsaman@videolan.org>

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • modules/mux/mpeg/ts.c

    r805699e r225300b  
    893893 
    894894    p_input->p_sys = p_stream = malloc( sizeof( ts_stream_t ) ); 
     895    if( !p_input->p_sys ) 
     896        return VLC_ENOMEM; 
    895897 
    896898    /* Init this new stream */ 
     
    10221024    p_stream->i_langs = 1+p_input->p_fmt->i_extra_languages; 
    10231025    p_stream->lang = malloc(p_stream->i_langs*3); 
     1026    if( !p_stream->lang ) 
     1027    { 
     1028        msg_Err( p_mux, "cannot add new stream, out of memory" ); 
     1029        p_stream->i_langs = 0; 
     1030        free( p_stream ); 
     1031        return VLC_ENOMEM; 
     1032    } 
    10241033    i = 1; 
    10251034    p_stream->lang[0] = 
     
    10591068            char *psz = p_input->p_fmt->p_extra_languages[i-1].psz_language; 
    10601069            const iso639_lang_t *pl = NULL; 
    1061   
     1070 
    10621071            if( strlen( psz ) == 2 ) 
    10631072            { 
     
    10861095    } 
    10871096 
    1088     /* Copy extra data (VOL for MPEG-4 and extra BitMapInfoHeader for VFW */ 
    1089     p_stream->i_decoder_specific_info = p_input->p_fmt->i_extra; 
    1090     if( p_stream->i_decoder_specific_info > 0 ) 
    1091     { 
    1092         p_stream->p_decoder_specific_info = 
    1093             malloc( p_stream->i_decoder_specific_info ); 
    1094         memcpy( p_stream->p_decoder_specific_info, 
    1095                 p_input->p_fmt->p_extra, 
    1096                 p_input->p_fmt->i_extra ); 
    1097     } 
    1098  
    10991097    /* Create decoder specific info for subt */ 
    11001098    if( p_stream->i_codec == VLC_FOURCC( 's', 'u','b', 't' ) ) 
     
    11051103        p_stream->p_decoder_specific_info = p = 
    11061104            malloc( p_stream->i_decoder_specific_info ); 
    1107  
    1108         p[0] = 0x10;    /* textFormat, 0x10 for 3GPP TS 26.245 */ 
    1109         p[1] = 0x00;    /* flags: 1b: associated video info flag 
    1110                                   3b: reserved 
    1111                                   1b: duration flag 
    1112                                   3b: reserved */ 
    1113         p[2] = 52;      /* remaining size */ 
    1114  
    1115         p += 3; 
    1116  
    1117         p[0] = p[1] = p[2] = p[3] = 0; p+=4;    /* display flags */ 
    1118         *p++ = 0;  /* horizontal justification (-1: left, 0 center, 1 right) */ 
    1119         *p++ = 1;  /* vertical   justification (-1: top, 0 center, 1 bottom) */ 
    1120  
    1121         p[0] = p[1] = p[2] = 0x00; p+=3;/* background rgb */ 
    1122         *p++ = 0xff;                    /* background a */ 
    1123  
    1124         p[0] = p[1] = 0; p += 2;        /* text box top */ 
    1125         p[0] = p[1] = 0; p += 2;        /* text box left */ 
    1126         p[0] = p[1] = 0; p += 2;        /* text box bottom */ 
    1127         p[0] = p[1] = 0; p += 2;        /* text box right */ 
    1128  
    1129         p[0] = p[1] = 0; p += 2;        /* start char */ 
    1130         p[0] = p[1] = 0; p += 2;        /* end char */ 
    1131         p[0] = p[1] = 0; p += 2;        /* default font id */ 
    1132  
    1133         *p++ = 0;                       /* font style flags */ 
    1134         *p++ = 12;                      /* font size */ 
    1135  
    1136         p[0] = p[1] = p[2] = 0x00; p+=3;/* foreground rgb */ 
    1137         *p++ = 0x00;                    /* foreground a */ 
    1138  
    1139         p[0] = p[1] = p[2] = 0; p[3] = 22; p += 4; 
    1140         memcpy( p, "ftab", 4 ); p += 4; 
    1141         *p++ = 0; *p++ = 1;             /* entry count */ 
    1142         p[0] = p[1] = 0; p += 2;        /* font id */ 
    1143         *p++ = 9;                       /* font name length */ 
    1144         memcpy( p, "Helvetica", 9 );    /* font name */ 
     1105        if( p ) 
     1106        { 
     1107            p[0] = 0x10;    /* textFormat, 0x10 for 3GPP TS 26.245 */ 
     1108            p[1] = 0x00;    /* flags: 1b: associated video info flag 
     1109                                    3b: reserved 
     1110                                    1b: duration flag 
     1111                                    3b: reserved */ 
     1112            p[2] = 52;      /* remaining size */ 
     1113 
     1114            p += 3; 
     1115 
     1116            p[0] = p[1] = p[2] = p[3] = 0; p+=4;    /* display flags */ 
     1117            *p++ = 0;  /* horizontal justification (-1: left, 0 center, 1 right) */ 
     1118            *p++ = 1;  /* vertical   justification (-1: top, 0 center, 1 bottom) */ 
     1119 
     1120            p[0] = p[1] = p[2] = 0x00; p+=3;/* background rgb */ 
     1121            *p++ = 0xff;                    /* background a */ 
     1122 
     1123            p[0] = p[1] = 0; p += 2;        /* text box top */ 
     1124            p[0] = p[1] = 0; p += 2;        /* text box left */ 
     1125            p[0] = p[1] = 0; p += 2;        /* text box bottom */ 
     1126            p[0] = p[1] = 0; p += 2;        /* text box right */ 
     1127 
     1128            p[0] = p[1] = 0; p += 2;        /* start char */ 
     1129            p[0] = p[1] = 0; p += 2;        /* end char */ 
     1130            p[0] = p[1] = 0; p += 2;        /* default font id */ 
     1131 
     1132            *p++ = 0;                       /* font style flags */ 
     1133            *p++ = 12;                      /* font size */ 
     1134 
     1135            p[0] = p[1] = p[2] = 0x00; p+=3;/* foreground rgb */ 
     1136            *p++ = 0x00;                    /* foreground a */ 
     1137 
     1138            p[0] = p[1] = p[2] = 0; p[3] = 22; p += 4; 
     1139            memcpy( p, "ftab", 4 ); p += 4; 
     1140            *p++ = 0; *p++ = 1;             /* entry count */ 
     1141            p[0] = p[1] = 0; p += 2;        /* font id */ 
     1142            *p++ = 9;                       /* font name length */ 
     1143            memcpy( p, "Helvetica", 9 );    /* font name */ 
     1144        } 
     1145        else p_stream->i_decoder_specific_info = 0; 
     1146    } 
     1147    else 
     1148    { 
     1149        /* Copy extra data (VOL for MPEG-4 and extra BitMapInfoHeader for VFW */ 
     1150        p_stream->i_decoder_specific_info = p_input->p_fmt->i_extra; 
     1151        if( p_stream->i_decoder_specific_info > 0 ) 
     1152        { 
     1153            p_stream->p_decoder_specific_info = 
     1154                malloc( p_stream->i_decoder_specific_info ); 
     1155            if( p_stream->p_decoder_specific_info ) 
     1156            { 
     1157                memcpy( p_stream->p_decoder_specific_info, 
     1158                        p_input->p_fmt->p_extra, 
     1159                        p_input->p_fmt->i_extra ); 
     1160            } 
     1161            else p_stream->i_decoder_specific_info = 0; 
     1162        } 
    11451163    } 
    11461164 
     
    22342252 
    22352253    if( p_sys->dvbpmt == NULL ) 
     2254    { 
    22362255        p_sys->dvbpmt = malloc( p_sys->i_num_pmt * sizeof(dvbpsi_pmt_t) ); 
     2256        if( !p_sys->dvbpmt ) 
     2257        { 
     2258            msg_Err( p_mux, "cannot generate a new pmt, out of memory" ); 
     2259            return; 
     2260        } 
     2261    } 
    22372262#ifdef HAVE_DVBPSI_SDT 
    22382263    if( p_sys->b_sdt )