changeset 340:da33058e94be

- Fixed a memory leak in plain.cc.
author jcid
date Wed, 17 Sep 2008 23:40:06 +0200
parents b464ea4ae6d7
children 215da0caf90b
files ChangeLog src/misc.c src/misc.h src/plain.cc
diffstat 4 files changed, 9 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Mon Sep 15 17:51:32 2008 +0200
+++ b/ChangeLog	Wed Sep 17 23:40:06 2008 +0200
@@ -114,6 +114,7 @@
  - Fixed a segfault bug in VERBATIM mode.
  - Made image inputs less of a special case by using x,y in ComplexButton.
  - Made forms show their action URL upon enter/leave mouse events (safety).
+ - Fixed a memory leak in plain.cc.
    Patches: place (AKA corvid)
 +- Fixed a problem with locally-installed dpis.
  - Added code for optional image loading (nice interface) very advanced!
--- a/src/misc.c	Mon Sep 15 17:51:32 2008 +0200
+++ b/src/misc.c	Wed Sep 17 23:40:06 2008 +0200
@@ -52,13 +52,13 @@
 /*
  * Takes a string and converts any tabs to spaces.
  */
-char *a_Misc_expand_tabs(const char *str)
+char *a_Misc_expand_tabs(const char *str, int len)
 {
    Dstr *New = dStr_new("");
-   int len, i, j, pos, old_pos;
+   int i, j, pos, old_pos;
    char *val;
 
-   if ((len = strlen(str))) {
+   if (len) {
       for (pos = 0, i = 0; i < len; i++) {
          if (str[i] == '\t') {
             /* Fill with whitespaces until the next tab. */
--- a/src/misc.h	Mon Sep 15 17:51:32 2008 +0200
+++ b/src/misc.h	Wed Sep 17 23:40:06 2008 +0200
@@ -10,7 +10,7 @@
 
 
 char *a_Misc_escape_chars(const char *str, const char *esc_set);
-char *a_Misc_expand_tabs(const char *str);
+char *a_Misc_expand_tabs(const char *str, int len);
 int a_Misc_get_content_type_from_data(void *Data, size_t Size,const char **PT);
 int a_Misc_content_type_check(const char *EntryType, const char *DetectedType);
 void a_Misc_parse_content_type(const char *str, char **major, char **minor,
--- a/src/plain.cc	Mon Sep 15 17:51:32 2008 +0200
+++ b/src/plain.cc	Wed Sep 17 23:40:06 2008 +0200
@@ -170,8 +170,8 @@
          }
          break;
       case ST_Eol:
-         data = dStrndup(Start + i - len, len);
-         DW2TB(dw)->addText(a_Misc_expand_tabs(data), widgetStyle);
+         data = a_Misc_expand_tabs(Start + i - len, len);
+         DW2TB(dw)->addText(data, widgetStyle);
          DW2TB(dw)->addParbreak(0, widgetStyle);
          dFree(data);
          if (Start[i] == '\r' && Start[i + 1] == '\n') ++i;
@@ -183,8 +183,8 @@
    }
    Start_Ofs += i - len;
    if (Eof && len) {
-      data = dStrndup(Start + i - len, len);
-      DW2TB(dw)->addText(a_Misc_expand_tabs(data), widgetStyle);
+      data = a_Misc_expand_tabs(Start + i - len, len);
+      DW2TB(dw)->addText(data, widgetStyle);
       DW2TB(dw)->addParbreak(0, widgetStyle);
       dFree(data);
       Start_Ofs += len;