Author: dab
Date: Tue Aug 14 19:31:06 2018
New Revision: 337814
URL: https://svnweb.freebsd.org/changeset/base/337814

Log:
  Fix several (more) memory leaks.
  
  A follow-up to r337812 to catch a couple more memory leaks that should
  have been included in that change.
  
  Reported by:  Coverity
  CID:          1296064, 1296067 (for real this time)
  MFC after:    3 days
  X-MFC-with:   r337812
  Sponsored by: Dell EMC

Modified:
  head/tests/sys/kqueue/libkqueue/main.c

Modified: head/tests/sys/kqueue/libkqueue/main.c
==============================================================================
--- head/tests/sys/kqueue/libkqueue/main.c      Tue Aug 14 19:21:31 2018        
(r337813)
+++ head/tests/sys/kqueue/libkqueue/main.c      Tue Aug 14 19:31:06 2018        
(r337814)
@@ -235,10 +235,14 @@ kevent_add(int kqfd, struct kevent *kev, 
         intptr_t  data,
         void      *udata)
 {
+    char *kev_str;
+    
     EV_SET(kev, ident, filter, flags, fflags, data, NULL);    
     if (kevent(kqfd, kev, 1, NULL, 0, NULL) < 0) {
-        printf("Unable to add the following kevent:\n%s\n",
-                kevent_to_str(kev));
+        kev_str = kevent_to_str(kev);
+       printf("Unable to add the following kevent:\n%s\n",
+                kev_str);
+       free(kev_str);
         err(1, "kevent(): %s", strerror(errno));
     }
 }
@@ -246,6 +250,9 @@ kevent_add(int kqfd, struct kevent *kev, 
 void
 kevent_cmp(struct kevent *k1, struct kevent *k2)
 {
+    char *kev1_str;
+    char *kev2_str;
+    
 /* XXX-
    Workaround for inconsistent implementation of kevent(2) 
  */
@@ -258,8 +265,12 @@ kevent_cmp(struct kevent *k1, struct kevent *k2)
       k1->data != k2->data || k1->udata != k2->udata ||
       k1->ext[0] != k2->ext[0] || k1->ext[1] != k2->ext[1] ||
       k1->ext[0] != k2->ext[2] || k1->ext[0] != k2->ext[3]) {
+        kev1_str = kevent_to_str(k1);
+       kev2_str = kevent_to_str(k2);
         printf("kevent_cmp: mismatch:\n  %s !=\n  %s\n", 
-              kevent_to_str(k1), kevent_to_str(k2));
+              kev1_str, kev2_str);
+       free(kev1_str);
+       free(kev2_str);
         abort();
     }
 }
_______________________________________________
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Reply via email to