Skip to content

Commit

Permalink
Fix some guarded free warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
leo-arch committed Jan 24, 2025
1 parent e55d07c commit de4407b
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 15 deletions.
9 changes: 3 additions & 6 deletions src/misc.c
Original file line number Diff line number Diff line change
Expand Up @@ -1479,8 +1479,7 @@ free_stuff(void)
free(jump_db);
}

if (pinned_dir)
free(pinned_dir);
free(pinned_dir);

// ADD FILTER TYPE CHECK!
if (filter.str) {
Expand Down Expand Up @@ -1601,10 +1600,8 @@ free_stuff(void)
if (workspaces && workspaces[0].path) {
i = MAX_WS;
while (--i >= 0) {
if (workspaces[i].path)
free(workspaces[i].path);
if (workspaces[i].name)
free(workspaces[i].name);
free(workspaces[i].path);
free(workspaces[i].name);
}
free(workspaces);
}
Expand Down
9 changes: 3 additions & 6 deletions src/readline.c
Original file line number Diff line number Diff line change
Expand Up @@ -912,12 +912,9 @@ my_rl_path_completion(const char *text, int state)
if (!state) {
char *temp;

if (dirname)
free(dirname);
if (filename)
free(filename);
if (users_dirname)
free(users_dirname);
free(dirname);
free(filename);
free(users_dirname);

/* tmp_text is true whenever text was dequoted */
char *p = tmp_text ? tmp_text : (char *)text;
Expand Down
3 changes: 1 addition & 2 deletions src/tabcomp.c
Original file line number Diff line number Diff line change
Expand Up @@ -2143,8 +2143,7 @@ tab_complete(const int what_to_do)
&& our_func == rl_completion_entry_function) {
(void)(*rl_ignore_some_completions_function)(matches);
if (matches == 0 || matches[0] == 0) {
if (matches)
free(matches);
free(matches);
free(text);
rl_ding();
return 0;
Expand Down
2 changes: 1 addition & 1 deletion src/utf8.h
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ utf8chr(const utf8_int8_t *src, utf8_int32_t chr)
c[0] = (utf8_int8_t)(0xe0 | (utf8_int8_t)(chr >> 12));
c[1] = (utf8_int8_t)(0x80 | (utf8_int8_t)((chr >> 6) & 0x3f));
c[2] = (utf8_int8_t)(0x80 | (utf8_int8_t)(chr & 0x3f));
} else { /* if (0 == ((int)0xffe00000 & chr)) { */
} else { /* ((int)0xffe00000 & chr) == 0 { */
/* 4-byte/21-bit utf8 code point
* (0b11110xxx 0b10xxxxxx 0b10xxxxxx 0b10xxxxxx) */
c[0] = (utf8_int8_t)(0xf0 | (utf8_int8_t)(chr >> 18));
Expand Down

0 comments on commit de4407b

Please sign in to comment.