mirror of
https://github.com/moonlight-stream/moonlight-common-c.git
synced 2026-10-27 06:19:58 +00:00
Fix memory leak if duplicate RTSP options are inserted
This commit is contained in:
1 parent
e2722dc837
commit
5ec839727a
1 file changed
+13
@@ -292,9 +292,22 @@ void insertOption(POPTION_ITEM* optionsHead, POPTION_ITEM opt) {
|
||||
|
||||
// Traverse the list and insert the new option at the end
|
||||
while (current != NULL) {
|
||||
// Check for self-insertion
|
||||
if (current == opt) {
|
||||
LC_ASSERT(current != opt);
|
||||
return;
|
||||
}
|
||||
|
||||
// Check for duplicate option; if so, replace the option currently there
|
||||
if (!strcmp(current->option, opt->option)) {
|
||||
if (current->flags & FLAG_ALLOCATED_OPTION_FIELDS) {
|
||||
free(current->option);
|
||||
free(current->content);
|
||||
}
|
||||
current->option = opt->option;
|
||||
current->content = opt->content;
|
||||
current->flags = opt->flags;
|
||||
free(opt);
|
||||
return;
|
||||
}
|
||||
if (current->next == NULL) {
|
||||
|
||||
Reference in new issue
Block a user