summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Sullivan <sullivan@src.gnome.org>2000-08-05 01:21:32 +0000
committerJohn Sullivan <sullivan@src.gnome.org>2000-08-05 01:21:32 +0000
commit8319c5d7efa9a28f1bc7d642c9cd5c18adf7e28c (patch)
treea0ecb81e299f3152d35440ad3fd47fe8a06cb6bd
parent09183d60ebf9ca6dcba5201b4ee297860676842b (diff)
downloadnautilus-8319c5d7efa9a28f1bc7d642c9cd5c18adf7e28c.tar.gz
Fixed unreported crash-at-boot bug I ran into when
I turned MALLOC_CHECK_=2 on. This is a good thing for everyone to run with (unless it slows things down hideously, which it doesn't seem to). * src/nautilus-simple-search-bar.c: (nautilus_simple_search_criteria_to_search_uri): This function (apologies to Pavel) crashed like a Russian helicopter and leaked like a Russian submarine. Fixed an off-by-one bug in a g_new0 that was trashing memory; removed another g_new0 call that was just leaking its results; called g_strfreev to free the results of a g_strsplit call.
-rw-r--r--ChangeLog15
-rw-r--r--src/nautilus-simple-search-bar.c8
2 files changed, 19 insertions, 4 deletions
diff --git a/ChangeLog b/ChangeLog
index 4100fa864..4ed673950 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,18 @@
+2000-08-04 John Sullivan <sullivan@eazel.com>
+
+ Fixed unreported crash-at-boot bug I ran into when
+ I turned MALLOC_CHECK_=2 on. This is a good thing for
+ everyone to run with (unless it slows things down hideously,
+ which it doesn't seem to).
+
+ * src/nautilus-simple-search-bar.c:
+ (nautilus_simple_search_criteria_to_search_uri):
+ This function (apologies to Pavel) crashed like a Russian
+ helicopter and leaked like a Russian submarine. Fixed an off-by-one
+ bug in a g_new0 that was trashing memory; removed another g_new0
+ call that was just leaking its results; called g_strfreev to
+ free the results of a g_strsplit call.
+
2000-08-04 Michael Engber <engber@eazel.com>
* libnautilus-extensions/nautilus-icon-container.c:
diff --git a/src/nautilus-simple-search-bar.c b/src/nautilus-simple-search-bar.c
index aefaad77b..f30e8e2cb 100644
--- a/src/nautilus-simple-search-bar.c
+++ b/src/nautilus-simple-search-bar.c
@@ -140,7 +140,6 @@ nautilus_simple_search_criteria_to_search_uri (const char *search_criteria)
g_return_val_if_fail (search_criteria != NULL, NULL);
- words = g_new0 (char *, strlen (search_criteria));
words = g_strsplit (search_criteria, " ", strlen (search_criteria));
/* FIXME: this should eventually be: length = strlen ("[file%3A%2F%2F%2F]"); */
length = strlen ("[file:///]");
@@ -148,7 +147,7 @@ nautilus_simple_search_criteria_to_search_uri (const char *search_criteria)
for (i = 0; words[i] != NULL; i++) {
length += strlen (words[i]) + strlen ("file_name contains & ");
}
- fragment = g_new0 (char, length);
+ fragment = g_new0 (char, length + 1);
/* FIXME: this should eventually be: sprintf (fragment, "[file%%3A%%2F%%2F%%2F]"); */
sprintf (fragment, "[file:///]");
if (words[0] != NULL) {
@@ -157,9 +156,10 @@ nautilus_simple_search_criteria_to_search_uri (const char *search_criteria)
strcat (fragment, words[i]);
strcat (fragment, " & ");
}
- strcat (fragment, "file_name contains ");
- strcat (fragment, words[i]);
+ strcat (fragment, "file_name contains ");
+ strcat (fragment, words[i]);
}
+ g_strfreev (words);
escaped_fragment = gnome_vfs_escape_string (fragment);
g_free (fragment);
search_uri = g_strconcat ("search:", escaped_fragment, NULL);