Bug 95291 - Possible memory leak in pulsecore/core-util.c
Summary: Possible memory leak in pulsecore/core-util.c
Status: RESOLVED FIXED
Alias: None
Product: PulseAudio
Classification: Unclassified
Component: core (show other bugs)
Version: unspecified
Hardware: Other All
: medium normal
Assignee: pulseaudio-bugs
QA Contact: pulseaudio-bugs
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-05-06 04:41 UTC by DEEPAK SRIVASTAVA
Modified: 2016-05-06 05:42 UTC (History)
1 user (show)

See Also:
i915 platform:
i915 features:


Attachments

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.