Skip to content
Snippets Groups Projects
Commit 1fc7c97f authored by Štěpán Balážik's avatar Štěpán Balážik
Browse files

kresc: fix unfree'd strings

parent 64b4c483
Branches
Tags
2 merge requests!254Knot Resolver 1.2.5,!194kresc: misc improvements
Pipeline #1596 passed with stages
in 1 minute and 38 seconds
...@@ -143,8 +143,15 @@ static void complete_members(EditLine * el, const char *str, ...@@ -143,8 +143,15 @@ static void complete_members(EditLine * el, const char *str,
//Prints all members. //Prints all members.
while (token) { while (token) {
char *member = afmt("%s.%s", table, token); char *member = afmt("%s.%s", table, token);
printf("\n%s (%s)", member, const char *member_type = get_type_name(member);
get_type_name(member)); if (member && member_type) {
printf("\n%s (%s)", member, member_type);
free(member);
free((void *)member_type);
} else if (member) {
printf("\n%s", member);
free(member);
}
token = strtok(NULL, "\n"); token = strtok(NULL, "\n");
matches++; matches++;
} }
...@@ -159,6 +166,7 @@ static void complete_members(EditLine * el, const char *str, ...@@ -159,6 +166,7 @@ static void complete_members(EditLine * el, const char *str,
if (member_type) { if (member_type) {
printf("\n%s.%s (%s)", table, printf("\n%s.%s (%s)", table,
token, member_type); token, member_type);
free((void *)member_type);
} else { } else {
printf("\n%s.%s", table, token); printf("\n%s.%s", table, token);
} }
...@@ -184,6 +192,9 @@ static void complete_members(EditLine * el, const char *str, ...@@ -184,6 +192,9 @@ static void complete_members(EditLine * el, const char *str,
complete_members_exit: complete_members_exit:
free(table); free(table);
if(t_type) {
free((void*)t_type);
}
} }
static void complete_globals(EditLine * el, const char *str, int str_len) static void complete_globals(EditLine * el, const char *str, int str_len)
...@@ -220,6 +231,7 @@ static void complete_globals(EditLine * el, const char *str, int str_len) ...@@ -220,6 +231,7 @@ static void complete_globals(EditLine * el, const char *str, int str_len)
el_deletestr(el, str_len); el_deletestr(el, str_len);
el_insertstr(el, lastmatch); el_insertstr(el, lastmatch);
} }
free(globals_tok);
} }
static unsigned char complete(EditLine * el, int ch) static unsigned char complete(EditLine * el, int ch)
...@@ -272,6 +284,9 @@ static unsigned char complete(EditLine * el, int ch) ...@@ -272,6 +284,9 @@ static unsigned char complete(EditLine * el, int ch)
//Current line is a function. //Current line is a function.
complete_function(el); complete_function(el);
} }
if (type) {
free((void *)type);
}
complete_exit: complete_exit:
tok_reset(tok); tok_reset(tok);
...@@ -300,13 +315,13 @@ static int init_tty(const char *path) ...@@ -300,13 +315,13 @@ static int init_tty(const char *path)
close(fd); close(fd);
return 1; return 1;
} }
g_tty = fdopen(fd, "r+"); g_tty = fdopen(fd, "r+");
if (!g_tty) { if (!g_tty) {
perror("While opening TTY"); perror("While opening TTY");
close(fd); close(fd);
return 1; return 1;
} }
// Switch to binary mode and consume the text "> ". // Switch to binary mode and consume the text "> ".
if (fprintf(g_tty, "__binary\n") < 0 || !fread(&addr, 2, 1, g_tty) if (fprintf(g_tty, "__binary\n") < 0 || !fread(&addr, 2, 1, g_tty)
|| fflush(g_tty)) { || fflush(g_tty)) {
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment