mirror of
https://github.com/ossrs/srs.git
synced 2025-03-09 15:49:59 +00:00
fix mem leak for delete[] SharedPtrMessage array, explicit free elems. remove srs_freepa. 0.9.95
This commit is contained in:
parent
0a1c0afe8d
commit
befde6acf7
15 changed files with 209 additions and 174 deletions
|
@ -513,9 +513,10 @@ int SrsRtmpConn::playing(SrsSource* source)
|
|||
srs_verbose("no packets in queue.");
|
||||
continue;
|
||||
}
|
||||
SrsAutoFree(SrsSharedPtrMessage*, msgs, true);
|
||||
|
||||
// sendout messages
|
||||
// @remark, becareful, all msgs must be free explicitly,
|
||||
// free by send_and_free_message or srs_freep.
|
||||
for (int i = 0; i < count; i++) {
|
||||
SrsSharedPtrMessage* msg = msgs[i];
|
||||
|
||||
|
@ -525,6 +526,13 @@ int SrsRtmpConn::playing(SrsSource* source)
|
|||
|
||||
srs_assert(msg);
|
||||
|
||||
// never use free msgs array, for it will memory leak.
|
||||
// if error, directly free msgs.
|
||||
if (ret != ERROR_SUCCESS) {
|
||||
srs_freep(msg);
|
||||
continue;
|
||||
}
|
||||
|
||||
// foreach msg, collect the duration.
|
||||
// @remark: never use msg when sent it, for the protocol sdk will free it.
|
||||
if (starttime < 0 || starttime > msg->header.timestamp) {
|
||||
|
@ -535,9 +543,14 @@ int SrsRtmpConn::playing(SrsSource* source)
|
|||
|
||||
if ((ret = rtmp->send_and_free_message(msg)) != ERROR_SUCCESS) {
|
||||
srs_error("send message to client failed. ret=%d", ret);
|
||||
return ret;
|
||||
break;
|
||||
}
|
||||
}
|
||||
// free the array itself.
|
||||
srs_freep(msgs);
|
||||
if (ret != ERROR_SUCCESS) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
// if duration specified, and exceed it, stop play live.
|
||||
// @see: https://github.com/winlinvip/simple-rtmp-server/issues/45
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue