Memory allocated by sqlite3_mprintf should be free'd by sqlite3_free
This was causing memory corruption thus making apropos(1) fail in some cases. Specifically following options were broken and should be fixed with this commit: -n option was causing a core dump apropos was giving warning when using -l and any of the section numbers as options as reported by paulg on current-users.
This commit is contained in:
parent
5ca372a8aa
commit
6947938705
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: apropos-utils.c,v 1.42 2019/04/14 07:59:56 abhinav Exp $ */
|
||||
/* $NetBSD: apropos-utils.c,v 1.43 2019/04/19 20:35:13 abhinav Exp $ */
|
||||
/*-
|
||||
* Copyright (c) 2011 Abhinav Upadhyay <er.abhinav.upadhyay@gmail.com>
|
||||
* All rights reserved.
|
||||
|
@ -31,7 +31,7 @@
|
|||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__RCSID("$NetBSD: apropos-utils.c,v 1.42 2019/04/14 07:59:56 abhinav Exp $");
|
||||
__RCSID("$NetBSD: apropos-utils.c,v 1.43 2019/04/19 20:35:13 abhinav Exp $");
|
||||
|
||||
#include <sys/queue.h>
|
||||
#include <sys/stat.h>
|
||||
|
@ -580,7 +580,7 @@ generate_search_query(query_args *args, const char *snippet_args[3])
|
|||
if ((temp = sqlite3_mprintf("%Q%c", args->sections[i], c)) == NULL)
|
||||
goto RETURN;
|
||||
concat(§ion_clause, temp);
|
||||
free(temp);
|
||||
sqlite3_free(temp);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -648,9 +648,9 @@ generate_search_query(query_args *args, const char *snippet_args[3])
|
|||
}
|
||||
|
||||
RETURN:
|
||||
free(machine_clause);
|
||||
free(section_clause);
|
||||
free(limit_clause);
|
||||
sqlite3_free(machine_clause);
|
||||
sqlite3_free(section_clause);
|
||||
sqlite3_free(limit_clause);
|
||||
return query;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue