mirror of
https://github.com/MidnightCommander/mc
synced 2025-01-21 10:42:07 +03:00
* subshell.c (exit_subshell): Prevent unwanted reuse of freed
pty_buffer. * complete.c (variable_completion_function): strncpy()->memcpy() changes are because we know there is no '\0' among the first length bytes. (insert_text): Likewise. (command_completion_function): Avoid memory leaks. (filename_completion_function): g_free handles NULL argument too, no need for the comparison. (try_complete): Likewise. (command_completion_function): Likewise. (free_completions): Likewise. * widget.c (gauge_callback): Fix for 64-bit arches (%*s len must be int, %3d takes int. (copy_region): g_free handles NULL argument too, no need for the comparison. (kill_line): Likewise. * find.c (do_search): Likewise. (init_find_vars): Likewise. (do_find): Likewise.
This commit is contained in:
parent
e5f21875a3
commit
2253379eb8
@ -1,3 +1,28 @@
|
|||||||
|
2004-09-04 Pavel S. Shirshov <pavelsh@mail.ru>
|
||||||
|
|
||||||
|
* subshell.c (exit_subshell): Prevent unwanted reuse of freed
|
||||||
|
pty_buffer.
|
||||||
|
* complete.c (variable_completion_function): strncpy()->memcpy()
|
||||||
|
changes are because we know there is no '\0' among the first
|
||||||
|
length bytes.
|
||||||
|
(insert_text): Likewise.
|
||||||
|
(command_completion_function): Avoid memory leaks.
|
||||||
|
(filename_completion_function): g_free handles NULL argument too,
|
||||||
|
no need for the comparison.
|
||||||
|
(try_complete): Likewise.
|
||||||
|
(command_completion_function): Likewise.
|
||||||
|
(free_completions): Likewise.
|
||||||
|
* widget.c (gauge_callback): Fix for 64-bit arches (%*s len must
|
||||||
|
be int, %3d takes int.
|
||||||
|
(copy_region): g_free handles NULL argument too, no need for
|
||||||
|
the comparison.
|
||||||
|
(kill_line): Likewise.
|
||||||
|
* find.c (do_search): Likewise.
|
||||||
|
(init_find_vars): Likewise.
|
||||||
|
(do_find): Likewise.
|
||||||
|
|
||||||
|
Based on patch from Jakub Jelinek <jakub@redhat.com>
|
||||||
|
|
||||||
2004-09-03 Pavel S. Shirshov <pavelsh@mail.ru>
|
2004-09-03 Pavel S. Shirshov <pavelsh@mail.ru>
|
||||||
|
|
||||||
* menu.c (destroy_menu): Fix warnings.
|
* menu.c (destroy_menu): Fix warnings.
|
||||||
|
@ -66,11 +66,8 @@ filename_completion_function (char *text, int state)
|
|||||||
if (!state){
|
if (!state){
|
||||||
char *temp;
|
char *temp;
|
||||||
|
|
||||||
if (dirname)
|
|
||||||
g_free (dirname);
|
g_free (dirname);
|
||||||
if (filename)
|
|
||||||
g_free (filename);
|
g_free (filename);
|
||||||
if (users_dirname)
|
|
||||||
g_free (users_dirname);
|
g_free (users_dirname);
|
||||||
|
|
||||||
if ((*text) && (temp = strrchr (text, PATH_SEP))){
|
if ((*text) && (temp = strrchr (text, PATH_SEP))){
|
||||||
@ -156,18 +153,12 @@ filename_completion_function (char *text, int state)
|
|||||||
mc_closedir (directory);
|
mc_closedir (directory);
|
||||||
directory = NULL;
|
directory = NULL;
|
||||||
}
|
}
|
||||||
if (dirname){
|
|
||||||
g_free (dirname);
|
g_free (dirname);
|
||||||
dirname = NULL;
|
dirname = NULL;
|
||||||
}
|
|
||||||
if (filename){
|
|
||||||
g_free (filename);
|
g_free (filename);
|
||||||
filename = NULL;
|
filename = NULL;
|
||||||
}
|
|
||||||
if (users_dirname){
|
|
||||||
g_free (users_dirname);
|
g_free (users_dirname);
|
||||||
users_dirname = NULL;
|
users_dirname = NULL;
|
||||||
}
|
|
||||||
return NULL;
|
return NULL;
|
||||||
} else {
|
} else {
|
||||||
char *temp;
|
char *temp;
|
||||||
@ -258,7 +249,7 @@ variable_completion_function (char *text, int state)
|
|||||||
*temp = '$';
|
*temp = '$';
|
||||||
if (isbrace)
|
if (isbrace)
|
||||||
temp [1] = '{';
|
temp [1] = '{';
|
||||||
strncpy (temp + 1 + isbrace, *env_p, p - *env_p);
|
memcpy (temp + 1 + isbrace, *env_p, p - *env_p);
|
||||||
if (isbrace)
|
if (isbrace)
|
||||||
strcpy (temp + 2 + (p - *env_p), "}");
|
strcpy (temp + 2 + (p - *env_p), "}");
|
||||||
else
|
else
|
||||||
@ -433,8 +424,7 @@ command_completion_function (char *text, int state)
|
|||||||
words = bash_reserved;
|
words = bash_reserved;
|
||||||
phase = 0;
|
phase = 0;
|
||||||
text_len = strlen (text);
|
text_len = strlen (text);
|
||||||
path = getenv ("PATH");
|
if (!path && (path = getenv ("PATH")) != NULL) {
|
||||||
if (path) {
|
|
||||||
p = path = g_strdup (path);
|
p = path = g_strdup (path);
|
||||||
path_end = strchr (p, 0);
|
path_end = strchr (p, 0);
|
||||||
while ((p = strchr (p, PATH_ENV_SEP))) {
|
while ((p = strchr (p, PATH_ENV_SEP))) {
|
||||||
@ -498,8 +488,8 @@ command_completion_function (char *text, int state)
|
|||||||
|
|
||||||
if (!found) {
|
if (!found) {
|
||||||
look_for_executables = 0;
|
look_for_executables = 0;
|
||||||
if (path)
|
|
||||||
g_free (path);
|
g_free (path);
|
||||||
|
path = NULL;
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
if ((p = strrchr (found, PATH_SEP)) != NULL) {
|
if ((p = strrchr (found, PATH_SEP)) != NULL) {
|
||||||
@ -756,7 +746,6 @@ try_complete (char *text, int *start, int *end, int flags)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (word)
|
|
||||||
g_free (word);
|
g_free (word);
|
||||||
|
|
||||||
return matches;
|
return matches;
|
||||||
@ -801,7 +790,7 @@ static int insert_text (WInput *in, char *text, ssize_t len)
|
|||||||
*(p++) = *(q++);
|
*(p++) = *(q++);
|
||||||
*p = 0;
|
*p = 0;
|
||||||
}
|
}
|
||||||
strncpy (in->buffer + start, text, len - start + end);
|
memcpy (in->buffer + start, text, len - start + end);
|
||||||
in->point += len;
|
in->point += len;
|
||||||
update_input (in, 1);
|
update_input (in, 1);
|
||||||
end += len;
|
end += len;
|
||||||
|
17
src/find.c
17
src/find.c
@ -512,10 +512,8 @@ do_search (struct Dlg_head *h)
|
|||||||
mc_closedir (dirp);
|
mc_closedir (dirp);
|
||||||
dirp = 0;
|
dirp = 0;
|
||||||
}
|
}
|
||||||
if (directory) {
|
|
||||||
g_free (directory);
|
g_free (directory);
|
||||||
directory = NULL;
|
directory = NULL;
|
||||||
}
|
|
||||||
dp = 0;
|
dp = 0;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@ -553,10 +551,7 @@ do_search (struct Dlg_head *h)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (directory) {
|
|
||||||
g_free (directory);
|
g_free (directory);
|
||||||
directory = NULL;
|
|
||||||
}
|
|
||||||
directory = tmp;
|
directory = tmp;
|
||||||
|
|
||||||
if (verbose){
|
if (verbose){
|
||||||
@ -630,10 +625,8 @@ init_find_vars (void)
|
|||||||
{
|
{
|
||||||
char *dir;
|
char *dir;
|
||||||
|
|
||||||
if (old_dir){
|
|
||||||
g_free (old_dir);
|
g_free (old_dir);
|
||||||
old_dir = 0;
|
old_dir = 0;
|
||||||
}
|
|
||||||
count = 0;
|
count = 0;
|
||||||
matches = 0;
|
matches = 0;
|
||||||
|
|
||||||
@ -948,10 +941,9 @@ find_file (char *start_dir, char *pattern, char *content, char **dirname,
|
|||||||
|
|
||||||
kill_gui ();
|
kill_gui ();
|
||||||
do_search (0); /* force do_search to release resources */
|
do_search (0); /* force do_search to release resources */
|
||||||
if (old_dir) {
|
|
||||||
g_free (old_dir);
|
g_free (old_dir);
|
||||||
old_dir = 0;
|
old_dir = 0;
|
||||||
}
|
|
||||||
return return_value;
|
return return_value;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -984,17 +976,14 @@ do_find (void)
|
|||||||
do_cd (filename, cd_exact);
|
do_cd (filename, cd_exact);
|
||||||
select_item (current_panel);
|
select_item (current_panel);
|
||||||
}
|
}
|
||||||
if (dirname)
|
|
||||||
g_free (dirname);
|
g_free (dirname);
|
||||||
if (filename)
|
|
||||||
g_free (filename);
|
g_free (filename);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (content)
|
|
||||||
g_free (content);
|
g_free (content);
|
||||||
dir_and_file_set = dirname && filename;
|
dir_and_file_set = dirname && filename;
|
||||||
if (dirname) g_free (dirname);
|
g_free (dirname);
|
||||||
if (filename) g_free (filename);
|
g_free (filename);
|
||||||
if (v == B_CANCEL)
|
if (v == B_CANCEL)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -659,6 +659,7 @@ exit_subshell (void)
|
|||||||
g_free (subshell_prompt);
|
g_free (subshell_prompt);
|
||||||
g_free (pty_buffer);
|
g_free (pty_buffer);
|
||||||
subshell_prompt = NULL;
|
subshell_prompt = NULL;
|
||||||
|
pty_buffer = NULL;
|
||||||
|
|
||||||
return quit;
|
return quit;
|
||||||
}
|
}
|
||||||
|
@ -620,7 +620,7 @@ gauge_callback (WGauge *g, int msg, int parm)
|
|||||||
if (!g->shown)
|
if (!g->shown)
|
||||||
printw ("%*s", gauge_len, "");
|
printw ("%*s", gauge_len, "");
|
||||||
else {
|
else {
|
||||||
long percentage, columns;
|
int percentage, columns;
|
||||||
long total = g->max, done = g->current;
|
long total = g->max, done = g->current;
|
||||||
|
|
||||||
if (total <= 0 || done < 0) {
|
if (total <= 0 || done < 0) {
|
||||||
@ -1241,7 +1241,6 @@ copy_region (WInput *in, int x_first, int x_last)
|
|||||||
if (last == first)
|
if (last == first)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (kill_buffer)
|
|
||||||
g_free (kill_buffer);
|
g_free (kill_buffer);
|
||||||
|
|
||||||
kill_buffer = g_strndup(in->buffer+first,last-first);
|
kill_buffer = g_strndup(in->buffer+first,last-first);
|
||||||
@ -1323,7 +1322,6 @@ yank (WInput *in)
|
|||||||
static void
|
static void
|
||||||
kill_line (WInput *in)
|
kill_line (WInput *in)
|
||||||
{
|
{
|
||||||
if (kill_buffer)
|
|
||||||
g_free (kill_buffer);
|
g_free (kill_buffer);
|
||||||
kill_buffer = g_strdup (&in->buffer [in->point]);
|
kill_buffer = g_strdup (&in->buffer [in->point]);
|
||||||
in->buffer [in->point] = 0;
|
in->buffer [in->point] = 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user