1
1
Fixed memory leak.
Fixed unclosed file descriptors.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
Этот коммит содержится в:
Andrew Borodin 2009-12-23 11:33:17 +00:00
родитель 4c3b02fe3f
Коммит b9400e140f
3 изменённых файлов: 20 добавлений и 11 удалений

Просмотреть файл

@ -2188,7 +2188,6 @@ edit_block_process_cmd (WEdit *edit, const char *shell_cmd, int block)
long start_mark, end_mark;
char buf[BUFSIZ];
FILE *script_home = NULL;
FILE *script_src = NULL;
FILE *block_file = NULL;
gchar *o, *h, *b, *tmp;
char *quoted_name = NULL;
@ -2197,16 +2196,23 @@ edit_block_process_cmd (WEdit *edit, const char *shell_cmd, int block)
h = g_strconcat (home_dir, PATH_SEP_STR EDIT_DIR, shell_cmd, (char *) NULL); /* home script */
b = concat_dir_and_file (home_dir, EDIT_BLOCK_FILE); /* block file */
if (!(script_home = fopen (h, "r"))) {
if (!(script_home = fopen (h, "w"))) {
script_home = fopen (h, "r");
if (script_home == NULL) {
FILE *script_src = NULL;
script_home = fopen (h, "w");
if (script_home == NULL) {
tmp = g_strconcat (_("Error creating script:"), h, (char *) NULL);
edit_error_dialog ("", get_sys_error (tmp));
g_free(tmp);
goto edit_block_process_cmd__EXIT;
}
if (!(script_src = fopen (o, "r"))) {
script_src = fopen (o, "r");
if (script_src == NULL) {
o = g_strconcat (mc_home_alt, shell_cmd, (char *) NULL);
if (!(script_src = fopen (o, "r"))) {
script_src = fopen (o, "r");
if (script_src == NULL) {
fclose (script_home);
unlink (h);
tmp = g_strconcat (_("Error reading script:"), o, (char *) NULL);
@ -2217,6 +2223,8 @@ edit_block_process_cmd (WEdit *edit, const char *shell_cmd, int block)
}
while (fgets (buf, sizeof (buf), script_src))
fputs (buf, script_home);
fclose (script_src);
if (fclose (script_home)) {
tmp = g_strconcat (_("Error closing script:"), h, (char *) NULL);
edit_error_dialog ("", get_sys_error (tmp));

Просмотреть файл

@ -148,7 +148,7 @@ int etags_set_definition_hash(const char *tagfile, const char *start_path,
/* open file with positions */
f = fopen (tagfile, "r");
if (!f)
if (f == NULL)
return 0;
while (fgets (buf, sizeof (buf), f)) {
@ -197,5 +197,6 @@ int etags_set_definition_hash(const char *tagfile, const char *start_path,
}
g_free(filename);
fclose (f);
return num;
}

Просмотреть файл

@ -225,7 +225,7 @@ do_read (void)
rpc_get (msock, RPC_INT, &handle, RPC_INT, &count, RPC_END);
data = malloc (count);
if (!data) {
if (data == NULL) {
send_status (-1, ENOMEM);
return;
}
@ -234,12 +234,12 @@ do_read (void)
n = read (handle, data, count);
if (verbose)
printf ("result=%d\n", n);
if (n < 0) {
if (n < 0)
send_status (-1, errno);
return;
else {
send_status (n, 0);
rpc_send (msock, RPC_BLOCK, n, data, RPC_END);
}
send_status (n, 0);
rpc_send (msock, RPC_BLOCK, n, data, RPC_END);
g_free (data);
}