Bug 95291

Summary: Possible memory leak in pulsecore/core-util.c
Product: PulseAudio Reporter: DEEPAK SRIVASTAVA <srivastava.d>
Component: coreAssignee: pulseaudio-bugs
Status: RESOLVED FIXED QA Contact: pulseaudio-bugs
Severity: normal    
Priority: medium CC: lennart
Version: unspecified   
Hardware: Other   
OS: All   
Whiteboard:
i915 platform: i915 features:

Description DEEPAK SRIVASTAVA 2016-05-06 04:41:20 UTC
In src/pulsecore/core-util.c, below function 
char *pa_getcwd(void) {
    size_t l = 128;

    for (;;) {
        char *p = pa_xmalloc(l);
        if (getcwd(p, l))
            return p;

        if (errno != ERANGE) {
            return NULL;
        }

        pa_xfree(p);
        l *= 2;
    }
}

If (errno != ERANGE) condition occur, then memory allocated for p will leak.
Comment 1 Arun Raghavan 2016-05-06 04:43:13 UTC
Hey Deepak, that looks legit. Want to send in a patch?
Comment 2 DEEPAK SRIVASTAVA 2016-05-06 04:51:09 UTC
Dear Arun, 
Patch has been sent to pulseaudio-discuss@lists.freedesktop.org.


BugLink: https://bugs.freedesktop.org/show_bug.cgi?id=95291

Signed-off-by: Deepak Srivastava <srivastava.d@samsung.com>
---
 src/pulsecore/core-util.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/src/pulsecore/core-util.c b/src/pulsecore/core-util.c
index 19c89a9..b6eb85a 100644
--- a/src/pulsecore/core-util.c
+++ b/src/pulsecore/core-util.c
@@ -2535,8 +2535,10 @@ char *pa_getcwd(void) {
         if (getcwd(p, l))
             return p;
 
-        if (errno != ERANGE)
+        if (errno != ERANGE) {
+            pa_xfree(p);
             return NULL;
+        }
 
         pa_xfree(p);
         l *= 2;
-- 
1.9.1
Comment 3 Arun Raghavan 2016-05-06 05:36:29 UTC
Sounds good. In general, it's enough to either file a bug or post to the ML. The list is preferred since patches there get collected on Patchwork and we have a single way to look at the review queue -- http://patchwork.freedesktop.org/project/pulseaudio/patches/

Also, you might want to subscribe to the mailing list, since posting to it is filtered (I'll let your mail through manually now).

Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.