- if (!c->last_packet_sent && c->state == HTTPSTATE_SEND_DATA_TRAILER) {
- /* prepare header */
- if (ctx->oformat && avio_open_dyn_buf(&ctx->pb) >= 0) {
- av_write_trailer(ctx);
- av_freep(&c->pb_buffer);
- avio_close_dyn_buf(ctx->pb, &c->pb_buffer);
+ if (ctx) {
+ if (!c->last_packet_sent && c->state == HTTPSTATE_SEND_DATA_TRAILER) {
+ /* prepare header */
+ if (ctx->oformat && avio_open_dyn_buf(&ctx->pb) >= 0) {
+ av_write_trailer(ctx);
+ av_freep(&c->pb_buffer);
+ avio_close_dyn_buf(ctx->pb, &c->pb_buffer);
+ }
+ }
+ for(i=0; i<ctx->nb_streams; i++)
+ av_freep(&ctx->streams[i]);
+ av_freep(&ctx->streams);
+ av_freep(&ctx->priv_data);