[tracker/unicode-lower] libtracker-data: The libunistring u16_tolower does things to the prealloc
- From: Philip Van Hoof <pvanhoof src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tracker/unicode-lower] libtracker-data: The libunistring u16_tolower does things to the prealloc
- Date: Mon, 28 Mar 2011 12:15:45 +0000 (UTC)
commit a8357465abb93feb514bcbe25dcee896034fa2f3
Author: Philip Van Hoof <philip codeminded be>
Date: Mon Mar 28 14:13:37 2011 +0200
libtracker-data: The libunistring u16_tolower does things to the prealloc
I got a double-free when passing sqlite3_free as destructor for the
SQLite sqlite3_result_text16. This made me conclude that libunistring's
prealloc stuff perhaps changes something to the ptr offset or something?
No idea, it works when I let u16_tolower allocate it all itself just fine.
src/libtracker-data/tracker-db-interface-sqlite.c | 14 ++++----------
1 files changed, 4 insertions(+), 10 deletions(-)
---
diff --git a/src/libtracker-data/tracker-db-interface-sqlite.c b/src/libtracker-data/tracker-db-interface-sqlite.c
index 92456fa..1a67aab 100644
--- a/src/libtracker-data/tracker-db-interface-sqlite.c
+++ b/src/libtracker-data/tracker-db-interface-sqlite.c
@@ -561,16 +561,9 @@ function_sparql_lower_case (sqlite3_context *context,
nInput = sqlite3_value_bytes16 (argv[0]);
- nOutput = nInput * 2 + 2;
- zOutput = sqlite3_malloc (nOutput);
-
- if (!zOutput) {
- return;
- }
+ zOutput = u16_tolower (zInput, nInput, zLocale, NULL, NULL, &written);
- u16_tolower (zInput, nInput, zLocale, NULL, &zOutput, &written);
-
- sqlite3_result_text16 (context, zOutput, -1, sqlite3_free);
+ sqlite3_result_text16 (context, zOutput, -1, free);
}
#elif HAVE_LIBICU
@@ -614,7 +607,8 @@ function_sparql_lower_case (sqlite3_context *context,
char zBuf[128];
sqlite3_snprintf (128, zBuf, "ICU error: u_strToLower()/u_strToUpper(): %s", u_errorName (status));
zBuf[127] = '\0';
- sqlite3_result_error(context, zBuf, -1);
+ sqlite3_free (zOutput);
+ sqlite3_result_error (context, zBuf, -1);
return;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]