Memory leak in SVDR LSTE

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,
I found that there is a memory leak in the SVDR LSTE command.
The socket file descriptor is fdopen'ed to dump the schedule
data, but the stream is never fclose'ed. The memory associated
with the stream is lost.

As simply fclosing the stream would close the socket as well, the
solution is to dup the socket first.

Patch attached.

Regards.

-- 
Stefan Huelswitt
s.huelswitt@xxxxxx  | http://www.muempf.de/
-------------- next part --------------
--- vdr-1.3.24-orig/svdrp.c	2005-05-06 15:47:39.000000000 +0200
+++ vdr-current-1.3.24/svdrp.c	2005-07-04 20:50:52.000000000 +0200
@@ -776,18 +776,25 @@
               p = strtok_r(NULL, delim, &strtok_next);
               }
         }
-     FILE *f = fdopen(file, "w");
-     if (f) {
-        if (Schedule)
-           Schedule->Dump(f, "215-", DumpMode, AtTime);
-        else
-           Schedules->Dump(f, "215-", DumpMode, AtTime);
-        fflush(f);
-        Reply(215, "End of EPG data");
-        // don't 'fclose(f)' here!
-        }
+     int fd=dup(file);
+     if (fd) {
+       FILE *f = fdopen(fd, "w");
+       if (f) {
+          if (Schedule)
+             Schedule->Dump(f, "215-", DumpMode, AtTime);
+          else
+             Schedules->Dump(f, "215-", DumpMode, AtTime);
+          fflush(f);
+          Reply(215, "End of EPG data");
+          fclose(f);
+          }
+       else {
+          Reply(451, "Can't open file connection");
+          close(fd);
+          }
+       }
      else
-        Reply(451, "Can't open file connection");
+       Reply(451, "Can't dup stream descriptor");
      }
   else
      Reply(451, "Can't get EPG data");

[Index of Archives]     [Linux Media]     [Asterisk]     [DCCP]     [Netdev]     [Xorg]     [Util Linux NG]     [Xfree86]     [Big List of Linux Books]     [Fedora Users]     [Fedora Women]     [ALSA Devel]     [Linux USB]

  Powered by Linux