Changeset 191

Show
Ignore:
Timestamp:
11/27/07 11:04:08 (10 months ago)
Author:
sip
Message:

Fixed memory leak in frame allocation

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • app_h324m/app_h324m.c

    r186 r191  
    778778                                        /* Packetize outgoing frame */ 
    779779                                        if ((send=create_ast_frame(frame,&vt))!=NULL) 
     780                                        { 
    780781                                                /* Send frame */ 
    781782                                                ast_write(pseudo,send); 
     783                                                /* Free frame */ 
     784                                                ast_frfree(send); 
     785                                        } 
    782786                                        /* Delete frame */ 
    783787                                        FrameDestroy(frame); 
  • app_mp4/app_mp4.c

    r190 r191  
    232232static int mp4_rtp_read(struct mp4rtp *p) 
    233233{ 
    234         struct ast_frame *f; 
     234        unsigned char buffer[sizeof(struct ast_frame) + AST_FRIENDLY_OFFSET + 1500]; 
     235        struct ast_frame *f = (struct ast_frame *) buffer; 
    235236        int next = 0; 
    236237        int last = 0; 
     
    262263                last = 1; 
    263264 
    264         /* malloc frame & data */ 
    265         f = (struct ast_frame *) malloc(sizeof(struct ast_frame) + AST_FRIENDLY_OFFSET + 1500); 
    266  
    267265        /* Unset */ 
    268         memset(f, 0, sizeof(struct ast_frame) + 1500); 
     266        memset(f, 0, sizeof(struct ast_frame) + 1500 + AST_FRIENDLY_OFFSET); 
    269267 
    270268        /* Let mp4 lib allocate memory */ 
     
    309307                return -1; 
    310308        } 
    311  
    312         /* if (f->frametype == AST_FRAME_VIDEO) { 
    313                 ast_log(LOG_DEBUG, "successfully read rtp video packet with %d bytes\n", f->datalen); 
    314         } else if (f->frametype == AST_FRAME_VOICE) { 
    315                 ast_log(LOG_DEBUG, "successfully read rtp audio packet with %d bytes\n", f->datalen); 
    316                 dump_buffer_hex("audio buffer:",f->data,f->datalen); 
    317         } */ 
    318309 
    319310        /* Write frame */ 
  • app_rtsp/app_rtsp.c

    r190 r191  
    986986static int rtsp_play(struct ast_channel *chan,char *ip, int port, char *url) 
    987987{ 
    988         struct ast_frame *f
    989         struct ast_frame *sendFrame
     988        struct ast_frame *f = NULL
     989        struct ast_frame *sendFrame = NULL
    990990 
    991991        int infds[5]; 
     
    10631063        infds[4] = player->videoRtcp; 
    10641064 
    1065  
    10661065        /* Send request */ 
    10671066        if (!RtspPlayerDescribe(player,url)) 
     
    10721071                goto rtsp_play_end; 
    10731072        } 
     1073 
     1074        /* malloc frame & data */ 
     1075        sendFrame = (struct ast_frame *) malloc(sizeof(struct ast_frame) + rtpSize); 
     1076 
     1077        /* Set data pointer */ 
     1078        rtpBuffer = (void*)sendFrame + AST_FRIENDLY_OFFSET; 
    10741079 
    10751080        /* log */ 
     
    13921397                        rtpLen = 0; 
    13931398                         
    1394                         /* malloc frame & data */ 
    1395                         sendFrame = (struct ast_frame *) malloc(sizeof(struct ast_frame) + rtpSize); 
    13961399                        /* Clean frame */ 
    13971400                        memset(sendFrame,0,sizeof(struct ast_frame) + rtpSize); 
    1398                         /* Set data pointer */ 
    1399                         rtpBuffer = (void*)sendFrame + AST_FRIENDLY_OFFSET; 
     1401 
    14001402 
    14011403                        /* Read rtp packet */ 
     
    15061508                /* Teardown */ 
    15071509                RtspPlayerTeardown(player); 
     1510 
     1511        /* Free frame */ 
     1512        if (sendFrame) 
     1513                /* Free memory */ 
     1514                free(sendFrame); 
    15081515 
    15091516        /* If ther was a sdp */ 
  • app_transcoder/app_transcoder.c

    r187 r191  
    173173        /* Send */ 
    174174        vtc->channel->tech->write_video(vtc->channel, send); 
     175 
     176        /* Free frame */ 
     177        free(send); 
    175178} 
    176179 
Copyright 2006 - Sergio García Murillo
Powered by Trac - Edgewall Software