tech@mandoc.bsd.lv
 help / color / mirror / Atom feed
From: Abhinav Upadhyay <er.abhinav.upadhyay@gmail.com>
To: tech@mdocml.bsd.lv
Subject: Possible Memory leak in mdoc_validate.c?
Date: Thu, 7 Apr 2016 23:08:42 +0530	[thread overview]
Message-ID: <CAHwRYJkz-fNjM=xBFXhhduSyMXX3G5MNWEuM8kJYpADu3FmHGA@mail.gmail.com> (raw)

Hi,

The function post_os in mdoc_validate.c has a static char *defbuf,
which doesn't seem to be free'd after allocation. Shouldn't it be
free'd and set to NULL if it was allocated?

On Linux, valgrind was reporting a warning that the memory allocated
here was still reachable, the following change got rid of that warning
for me.

Index: dist/mdoc_validate.c
===================================================================
RCS file: /cvsroot/src/external/bsd/mdocml/dist/mdoc_validate.c,v
retrieving revision 1.9
diff -u -r1.9 mdoc_validate.c
--- dist/mdoc_validate.c    7 Jan 2016 20:05:41 -0000    1.9
+++ dist/mdoc_validate.c    3 Apr 2016 11:51:09 -0000
@@ -2289,6 +2289,10 @@
                 utsname.sysname, utsname.release);
     }
     mdoc->meta.os = mandoc_strdup(defbuf);
+    if (NULL != defbuf) {
+        free(defbuf);
+        defbuf = NULL;
+    }
 #endif /*!OSNAME*/

 out:
--
 To unsubscribe send an email to tech+unsubscribe@mdocml.bsd.lv

             reply	other threads:[~2016-04-07 17:38 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-04-07 17:38 Abhinav Upadhyay [this message]
2016-04-07 18:10 ` Ingo Schwarze
2016-04-07 19:21   ` Abhinav Upadhyay

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAHwRYJkz-fNjM=xBFXhhduSyMXX3G5MNWEuM8kJYpADu3FmHGA@mail.gmail.com' \
    --to=er.abhinav.upadhyay@gmail.com \
    --cc=tech@mdocml.bsd.lv \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).