texinfo-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[8097] XS avoid memory leaks


From: gavinsmith0123
Subject: [8097] XS avoid memory leaks
Date: Thu, 16 Aug 2018 12:24:41 -0400 (EDT)

Revision: 8097
          http://svn.sv.gnu.org/viewvc/?view=rev&root=texinfo&revision=8097
Author:   gavin
Date:     2018-08-16 12:24:40 -0400 (Thu, 16 Aug 2018)
Log Message:
-----------
XS avoid memory leaks

Modified Paths:
--------------
    trunk/ChangeLog
    trunk/tp/Texinfo/XS/misc.c

Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog     2018-08-16 16:11:53 UTC (rev 8096)
+++ trunk/ChangeLog     2018-08-16 16:24:40 UTC (rev 8097)
@@ -1,5 +1,10 @@
 2018-08-16  Gavin Smith  <address@hidden>
 
+       * tp/Texinfo/XS/xspara.c (xs_unicode_text, xs_process_text):
+       Use static buffers to avoid memory leaks.
+
+2018-08-16  Gavin Smith  <address@hidden>
+
        * tp/Texinfo/XS/xspara.c (xspara_get_pending, xspara_add_pending_word)
        xspara_end, xspara_add_next, xspara_add_text): Save storage for 
        text buffers in static variables to avoid memory leak.

Modified: trunk/tp/Texinfo/XS/misc.c
===================================================================
--- trunk/tp/Texinfo/XS/misc.c  2018-08-16 16:11:53 UTC (rev 8096)
+++ trunk/tp/Texinfo/XS/misc.c  2018-08-16 16:24:40 UTC (rev 8097)
@@ -437,9 +437,11 @@
 char *
 xs_process_text (char *text)
 {
-  char *new, *p, *q;
+  static char *new;
+  char *p, *q;
 
-  new = strdup (text);
+  new = realloc (new, strlen (text) + 1);
+  strcpy (new, text);
 
   p = q = new;
   while (*p)
@@ -489,7 +491,7 @@
 xs_unicode_text (char *text, int in_code)
 {
   char *p, *q;
-  char *new;
+  static char *new;
   int new_space, new_len;
 
   dTHX; /* Perl boilerplate. */
@@ -499,7 +501,7 @@
 
   p = text;
   new_space = strlen (text);
-  new = malloc (new_space + 1);
+  new = realloc (new, new_space + 1);
   new_len = 0;
 #define ADD3(s) \
   if (new_len + 2 >= new_space - 1)               \




reply via email to

[Prev in Thread] Current Thread [Next in Thread]