+2013-01-02 David Benjamin <davidben@Savannah>
+ * src/search.c (parse_syntax): Fix blatantly and dangerously incorrect code for
+ deleting old syntaxes.
+
2013-01-02 Mike Frysinger <vapier@gentoo.org>
* src/files.c (cwd_tab_completion): Remove unnecessary variables
* src/search.c (search_init): Fix gcc complaints on certain versions
void parse_syntax(char *ptr)
{
const char *fileregptr = NULL, *nameptr = NULL;
- syntaxtype *tmpsyntax;
+ syntaxtype *tmpsyntax, *prev_syntax;
exttype *endext = NULL;
/* The end of the extensions list for this syntax. */
/* Search for a duplicate syntax name. If we find one, free it, so
* that we always use the last syntax with a given name. */
+ prev_syntax = NULL;
for (tmpsyntax = syntaxes; tmpsyntax != NULL;
tmpsyntax = tmpsyntax->next) {
if (strcmp(nameptr, tmpsyntax->desc) == 0) {
- syntaxtype *prev_syntax = tmpsyntax;
+ syntaxtype *old_syntax = tmpsyntax;
+
+ if (endsyntax == tmpsyntax)
+ endsyntax = prev_syntax;
tmpsyntax = tmpsyntax->next;
- free(prev_syntax);
+ if (prev_syntax != NULL)
+ prev_syntax->next = tmpsyntax;
+ else
+ syntaxes = tmpsyntax;
+
+ free(old_syntax->desc);
+ free(old_syntax);
break;
}
+ prev_syntax = tmpsyntax;
}
if (syntaxes == NULL) {