Ticket #5004: libs_libmythtv_videoout_fb.cpp-remove-string-leak.patch

File libs_libmythtv_videoout_fb.cpp-remove-string-leak.patch, 1.2 KB (added by Erik Hovland <erik@…>, 13 years ago)

removes strdup (and also an unneeded null check)

  • libs/libmythtv/videoout_directfb.cpp

    In VideoOutputDirectfb::GetRefreshRate() there is a call to getenv. If
    From: Erik Hovland <erik@hovland.org>
    that returns null the conditional will do a strdup of a constant
    string and use that to open up the frame buffer device instead.
    That strdup is an allocation and it will leak a string since it is
    not freed later.
    getenv doesn't leak because it sets the string pointer to the
    location of the string in the environ string list. That is a
    static global that the process.
     libs/libmythtv/videoout_directfb.cpp |    4 ++--
     1 files changed, 2 insertions(+), 2 deletions(-)
    diff --git a/libs/libmythtv/videoout_directfb.cpp b/libs/libmythtv/videoout_directfb.cpp
    index c681d4b..1f06dda 100644
    a b int VideoOutputDirectfb::GetRefreshRate(void) 
    306306    long htotal;
    307307    long vtotal;
    308308    char *fb_dev_name = NULL;
    309     if (!fb_dev_name && !(fb_dev_name = getenv("FRAMEBUFFER")))
    310         fb_dev_name = strdup("/dev/fb0");
     309    if (!(fb_dev_name = getenv("FRAMEBUFFER")))
     310        fb_dev_name = "/dev/fb0";
    312312    fh = open(fb_dev_name, O_RDONLY);
    313313    if (-1 == fh) {