[tracker] Avoid invalid memory accesses.
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tracker] Avoid invalid memory accesses.
- Date: Wed, 3 Mar 2010 16:47:31 +0000 (UTC)
commit 4e3acd78e673fab6df429ccf59fab37733739806
Author: Carlos Garnacho <carlos lanedo com>
Date: Wed Mar 3 17:43:24 2010 +0100
Avoid invalid memory accesses.
When there was a duplicated path in tracker_path_list_filter_duplicates(),
the first of both items would be freed, but string operations were still
being performed on such freed data.
src/libtracker-common/tracker-file-utils.c | 11 ++++-------
1 files changed, 4 insertions(+), 7 deletions(-)
---
diff --git a/src/libtracker-common/tracker-file-utils.c b/src/libtracker-common/tracker-file-utils.c
index bed45ff..df14335 100644
--- a/src/libtracker-common/tracker-file-utils.c
+++ b/src/libtracker-common/tracker-file-utils.c
@@ -459,17 +459,14 @@ tracker_path_list_filter_duplicates (GSList *roots,
l2 = l2->next;
}
- /* Make sure the path doesn't have the '/' suffix. */
- p = strrchr (path, G_DIR_SEPARATOR);
+ if (G_LIKELY (!reset)) {
+ p = strrchr (path, G_DIR_SEPARATOR);
- if (p) {
- if (*(p + 1) == '\0') {
+ /* Make sure the path doesn't have the '/' suffix. */
+ if (p && !p[1]) {
*p = '\0';
}
- }
- /* Continue in list unless reset. */
- if (G_LIKELY (!reset)) {
l1 = l1->next;
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]