tech@mandoc.bsd.lv
 help / color / mirror / Atom feed
* Possible Memory leak in mdoc_validate.c?
@ 2016-04-07 17:38 Abhinav Upadhyay
  2016-04-07 18:10 ` Ingo Schwarze
  0 siblings, 1 reply; 3+ messages in thread
From: Abhinav Upadhyay @ 2016-04-07 17:38 UTC (permalink / raw)
  To: tech

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

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2016-04-07 19:21 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-04-07 17:38 Possible Memory leak in mdoc_validate.c? Abhinav Upadhyay
2016-04-07 18:10 ` Ingo Schwarze
2016-04-07 19:21   ` Abhinav Upadhyay

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).