summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard Jones <rjones@trick.home.annexia.org>2009-08-06 14:35:46 +0100
committerRichard Jones <rjones@trick.home.annexia.org>2009-08-06 15:03:56 +0100
commit690472768c2b94daaca3c9980bc31fcd6b09e8b7 (patch)
treeb019793409ae028183c0829e9cdff5f5a3f416d4
parent2b8019e56cf40fe8e8223b4e57cfd590495e8e60 (diff)
downloadlibguestfs-690472768c2b94daaca3c9980bc31fcd6b09e8b7.tar.gz
libguestfs-690472768c2b94daaca3c9980bc31fcd6b09e8b7.tar.xz
libguestfs-690472768c2b94daaca3c9980bc31fcd6b09e8b7.zip
Fix: segfault in tab completion (RHBZ#516024).
Actually this fixes two bugs: 'strs' was not being freed on every path, and the tab completion segfault described in the bug report.
-rw-r--r--fish/destpaths.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/fish/destpaths.c b/fish/destpaths.c
index f4f13188..8b6173aa 100644
--- a/fish/destpaths.c
+++ b/fish/destpaths.c
@@ -113,7 +113,7 @@ complete_dest_paths_generator (const char *text, int state)
size_t i; \
size_t n = count_strings (strs); \
\
- if ( ! xalloc_oversized (nr_words + n, sizeof (struct word))) { \
+ if ( n > 0 && ! xalloc_oversized (nr_words + n, sizeof (struct word))) { \
struct word *w; \
w = realloc (words, sizeof (struct word) * (nr_words + n)); \
\
@@ -129,8 +129,8 @@ complete_dest_paths_generator (const char *text, int state)
nr_words++; \
} \
} \
- free (strs); \
} \
+ free (strs); \
} \
} while (0)