From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 20425 invoked from network); 4 Oct 2021 20:24:39 -0000 Received: from bsd.lv (HELO mandoc.bsd.lv) (66.111.2.12) by inbox.vuxu.org with ESMTPUTF8; 4 Oct 2021 20:24:39 -0000 Received: from fantadrom.bsd.lv (localhost [127.0.0.1]) by mandoc.bsd.lv (OpenSMTPD) with ESMTP id 8af3c2ee for ; Mon, 4 Oct 2021 15:24:37 -0500 (EST) Received: from localhost (mandoc.bsd.lv [local]) by mandoc.bsd.lv (OpenSMTPD) with ESMTPA id 2191d852 for ; Mon, 4 Oct 2021 15:24:37 -0500 (EST) Date: Mon, 4 Oct 2021 15:24:37 -0500 (EST) X-Mailinglist: mandoc-source Reply-To: source@mandoc.bsd.lv MIME-Version: 1.0 From: schwarze@mandoc.bsd.lv To: source@mandoc.bsd.lv Subject: mandoc: In man(1) mode, properly clean up the resn[] result array after X-Mailer: activitymail 1.26, http://search.cpan.org/dist/activitymail/ Content-Type: text/plain; charset=utf-8 Message-ID: Log Message: ----------- In man(1) mode, properly clean up the resn[] result array after processing each name given on the command line. Failure to do so resulted in a memory leak of about 50 kilobytes per name given on the command line. Since man(1) uses a few Megabytes of memory anyway and people rarely give hundreds of names on the command line, this leak did not cause practical problems, but cleaning up properly is better in any case. Modified Files: -------------- mandoc: main.c Revision Data ------------- Index: main.c =================================================================== RCS file: /home/cvs/mandoc/mandoc/main.c,v retrieving revision 1.358 retrieving revision 1.359 diff -Lmain.c -Lmain.c -u -p -r1.358 -r1.359 --- main.c +++ main.c @@ -516,6 +516,9 @@ main(int argc, char *argv[]) memcpy(res + ressz, resn, sizeof(*resn) * resnsz); ressz += resnsz; + free(resn); + resn = NULL; + resnsz = 0; continue; } @@ -554,6 +557,10 @@ main(int argc, char *argv[]) res = mandoc_reallocarray(res, ressz + 1, sizeof(*res)); memcpy(res + ressz++, resn + ib, sizeof(*resn)); + memset(resn + ib, 0, sizeof(*resn)); + mansearch_free(resn, resnsz); + resn = NULL; + resnsz = 0; } /* apropos(1), whatis(1): Process the full search expression. */ -- To unsubscribe send an email to source+unsubscribe@mandoc.bsd.lv