fixed invalid free() and missing break;

xkbcommon
Alessandro Mauri 4 years ago
parent de6db78896
commit e14049d5b6
  1. 6
      hkd.c

@ -246,6 +246,7 @@ int main (int argc, char *argv[])
switch (opc) { switch (opc) {
case 'v': case 'v':
vflag = 1; vflag = 1;
break;
case 'c': case 'c':
ext_config_file = malloc(strlen(optarg) + 1); ext_config_file = malloc(strlen(optarg) + 1);
if (!ext_config_file) if (!ext_config_file)
@ -643,6 +644,7 @@ void parse_config_file (void)
struct key_buffer kb; struct key_buffer kb;
for (int linenum = 1;; linenum++) { for (int linenum = 1;; linenum++) {
int fuzzy = 0, tmp; int fuzzy = 0, tmp;
char * linebegin = NULL;
char *line = NULL, *keys = NULL, *command = NULL; char *line = NULL, *keys = NULL, *command = NULL;
size_t linelen = 0; size_t linelen = 0;
@ -651,6 +653,8 @@ void parse_config_file (void)
if (linelen < 2) if (linelen < 2)
continue; continue;
linebegin = line;
// Remove leading spaces // Remove leading spaces
while (isspace(line[0]) && linelen > 1) { while (isspace(line[0]) && linelen > 1) {
line = &line[1]; line = &line[1];
@ -659,7 +663,7 @@ void parse_config_file (void)
// Skip comments and blank lines // Skip comments and blank lines
if (line[0] == '#' || !line[0]) { if (line[0] == '#' || !line[0]) {
free(line); free(linebegin);
continue; continue;
} }
for (size_t i = 1; i < linelen; i++) { for (size_t i = 1; i < linelen; i++) {

Loading…
Cancel
Save