diff options
author | Carlos Garnacho <carlosg@gnome.org> | 2014-01-20 20:17:40 +0100 |
---|---|---|
committer | Carlos Garnacho <carlosg@gnome.org> | 2014-01-20 20:17:40 +0100 |
commit | c32330ea9c90229d1cee0207c68ee3a66a30ea0e (patch) | |
tree | b8310533a0e81a6ccdc1654b1bd5f982993b9182 | |
parent | 7061e59d996c69cc2e26965e108d56335b5f0556 (diff) | |
download | tracker-wip/passive-extraction.tar.gz |
extract: Plug a leakwip/passive-extraction
If the string being processed is detected as UTF16, the "utf8"
variable would already contain a malloc()'ed string, so the
GString would be leaked altogether.
Then, ensure the string is freed if already converted from UTF16,
and spare the utf8 validation too, since we already know the string
is valid utf8.
-rw-r--r-- | src/tracker-extract/tracker-read.c | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/src/tracker-extract/tracker-read.c b/src/tracker-extract/tracker-read.c index c9087ef95..32db4596a 100644 --- a/src/tracker-extract/tracker-read.c +++ b/src/tracker-extract/tracker-read.c @@ -203,16 +203,19 @@ process_whole_string (GString *s) } } - if (!utf8) { + if (utf8) { + n_valid_utf8_bytes = utf8_len; + g_string_free (s, TRUE); + } else { utf8_len = s->len; utf8 = g_string_free (s, FALSE); - } - /* Get number of valid UTF-8 bytes found */ - tracker_text_validate_utf8 (utf8, - utf8_len, - NULL, - &n_valid_utf8_bytes); + /* Get number of valid UTF-8 bytes found */ + tracker_text_validate_utf8 (utf8, + utf8_len, + NULL, + &n_valid_utf8_bytes); + } /* A valid UTF-8 file will be that where all read bytes are valid, * with a margin of 3 bytes for the last UTF-8 character which might |