Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

memory leak #1119

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions trunk/src/kernel/srs_kernel_ts.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,8 @@ SrsTsMessage* SrsTsMessage::detach()
cp->sid = sid;
cp->PES_packet_length = PES_packet_length;
cp->continuity_counter = continuity_counter;
//use the origin msg's payload, just free ours
srs_freep(cp->payload);
cp->payload = payload;
payload = NULL;
return cp;
Expand Down
12 changes: 10 additions & 2 deletions trunk/src/main/srs_main_ingest_hls.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -902,25 +902,29 @@ int SrsIngestSrsOutput::parse_message_queue()
nb_videos--;
}
queue.erase(it);

// parse the stream.
SrsStream avs;
if ((ret = avs.initialize(msg->payload->bytes(), msg->payload->length())) != ERROR_SUCCESS) {
srs_error("mpegts: initialize av stream failed. ret=%d", ret);
srs_freep(msg);
return ret;
}

// publish audio or video.
if (msg->channel->stream == SrsTsStreamVideoH264) {
if ((ret = on_ts_video(msg, &avs)) != ERROR_SUCCESS) {
srs_freep(msg);
return ret;
}
}
if (msg->channel->stream == SrsTsStreamAudioAAC) {
if ((ret = on_ts_audio(msg, &avs)) != ERROR_SUCCESS) {
srs_freep(msg);
return ret;
}
}
//release detached ts msg
srs_freep(msg);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could use auto free to free the message.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

}

return ret;
Expand All @@ -936,25 +940,29 @@ int SrsIngestSrsOutput::flush_message_queue()

SrsTsMessage* msg = it->second;
queue.erase(it);

// parse the stream.
SrsStream avs;
if ((ret = avs.initialize(msg->payload->bytes(), msg->payload->length())) != ERROR_SUCCESS) {
srs_error("mpegts: initialize av stream failed. ret=%d", ret);
srs_freep(msg);
return ret;
}

// publish audio or video.
if (msg->channel->stream == SrsTsStreamVideoH264) {
if ((ret = on_ts_video(msg, &avs)) != ERROR_SUCCESS) {
srs_freep(msg);
return ret;
}
}
if (msg->channel->stream == SrsTsStreamAudioAAC) {
if ((ret = on_ts_audio(msg, &avs)) != ERROR_SUCCESS) {
srs_freep(msg);
return ret;
}
}
//release detached ts msg
srs_freep(msg);
}

return ret;
Expand Down