]> git.ipfire.org Git - thirdparty/tvheadend.git/commitdiff
Fix memory leak in HTSP-Server master
authorFlole <Flole998@users.noreply.github.com>
Sat, 9 Aug 2025 17:20:22 +0000 (19:20 +0200)
committerFlole <Flole998@users.noreply.github.com>
Sun, 10 Aug 2025 10:53:43 +0000 (12:53 +0200)
src/htsp_server.c

index a690ab316cf3f5f8c1acddb0a8a222caae04d9e9..e3c8ea4ac3a09401488fd2f4924cfa0084aba2e3 100644 (file)
@@ -1883,16 +1883,20 @@ htsp_method_epgQuery(htsp_connection_t *htsp, htsmsg_t *in)
 
   /* Optional */
   if(!(htsmsg_get_u32(in, "channelId", &u32))) {
-    if (!(ch = channel_find_by_id(u32)))
+    if (!(ch = channel_find_by_id(u32))) {
+         epg_query_free(&eq);
       return htsp_error(htsp, N_("Channel does not exist"));
-    else
+       } else {
       eq.channel = strdup(idnode_uuid_as_str(&ch->ch_id, ubuf));
+       }
   }
   if(!(htsmsg_get_u32(in, "tagId", &u32))) {
-    if (!(ct = htsp_channel_tag_find_by_id(htsp, u32)))
+    if (!(ct = htsp_channel_tag_find_by_id(htsp, u32))) {
+         epg_query_free(&eq);
       return htsp_error(htsp, N_("Channel tag does not exist"));
-    else
+       } else {
       eq.channel_tag = strdup(idnode_uuid_as_str(&ct->ct_id, ubuf));
+       }
   }
   if (!htsmsg_get_u32(in, "contentType", &u32)) {
     if(htsp->htsp_version < 6) u32 <<= 4;
@@ -1912,8 +1916,10 @@ htsp_method_epgQuery(htsp_connection_t *htsp, htsmsg_t *in)
   tvhtrace(LS_HTSP, "min_duration %d and max_duration %d", min_duration, max_duration);
 
   /* Check access */
-  if (ch && !htsp_user_access_channel(htsp, ch))
+  if (ch && !htsp_user_access_channel(htsp, ch)) {
+    epg_query_free(&eq);
     return htsp_error(htsp, N_("User does not have access"));
+  }
 
   /* Query */
   epg_query(&eq, htsp->htsp_granted_access);