From d61666920e33d15d25ac6381e4f4c64f66165493 Mon Sep 17 00:00:00 2001 From: jcid Date: Wed, 17 Sep 2008 23:40:06 +0200 Subject: - Fixed a memory leak in plain.cc. --- src/misc.c | 6 +++--- src/misc.h | 2 +- src/plain.cc | 8 ++++---- 3 files changed, 8 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/misc.c b/src/misc.c index 7cb0b9ff..681fbdb9 100644 --- a/src/misc.c +++ b/src/misc.c @@ -52,13 +52,13 @@ char *a_Misc_escape_chars(const char *str, const char *esc_set) /* * 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. */ diff --git a/src/misc.h b/src/misc.h index 2659875b..d8de0238 100644 --- a/src/misc.h +++ b/src/misc.h @@ -10,7 +10,7 @@ extern "C" { 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, diff --git a/src/plain.cc b/src/plain.cc index 9a656907..34672e3c 100644 --- a/src/plain.cc +++ b/src/plain.cc @@ -170,8 +170,8 @@ void DilloPlain::write(void *Buf, uint_t BufSize, int Eof) } 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 @@ void DilloPlain::write(void *Buf, uint_t BufSize, int Eof) } 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; -- cgit v1.2.3