1
0
mirror of https://git.tartarus.org/simon/putty.git synced 2025-01-10 01:48:00 +00:00

Add an assortment of missing frees, and one missing file close. Mostly

on error paths, although the one in PSFTP's wildcard_iterate will come
up in normal usage.

[originally from svn r9916]
This commit is contained in:
Simon Tatham 2013-07-11 17:43:41 +00:00
parent c925526e3f
commit cc4f38df14
2 changed files with 16 additions and 1 deletions

16
pscp.c
View File

@ -773,6 +773,8 @@ void scp_sftp_listdir(char *dirname)
*/ */
for (i = 0; i < nnames; i++) for (i = 0; i < nnames; i++)
printf("%s\n", ournames[i].longname); printf("%s\n", ournames[i].longname);
sfree(ournames);
} }
} }
@ -891,6 +893,7 @@ int scp_send_filename(char *name, uint64 size, int permissions)
if (!scp_sftp_filehandle) { if (!scp_sftp_filehandle) {
tell_user(stderr, "pscp: unable to open %s: %s", tell_user(stderr, "pscp: unable to open %s: %s",
fullname, fxp_error()); fullname, fxp_error());
sfree(fullname);
errs++; errs++;
return 1; return 1;
} }
@ -1059,6 +1062,7 @@ int scp_send_dirname(char *name, int modes)
!(attrs.permissions & 0040000)) { !(attrs.permissions & 0040000)) {
tell_user(stderr, "unable to create directory %s: %s", tell_user(stderr, "unable to create directory %s: %s",
fullname, err); fullname, err);
sfree(fullname);
errs++; errs++;
return 1; return 1;
} }
@ -1279,6 +1283,7 @@ int scp_get_sink_action(struct scp_sink_action *act)
if (!ret || !(attrs.flags & SSH_FILEXFER_ATTR_PERMISSIONS)) { if (!ret || !(attrs.flags & SSH_FILEXFER_ATTR_PERMISSIONS)) {
tell_user(stderr, "unable to identify %s: %s", fname, tell_user(stderr, "unable to identify %s: %s", fname,
ret ? "file type not supplied" : fxp_error()); ret ? "file type not supplied" : fxp_error());
if (must_free_fname) sfree(fname);
errs++; errs++;
return 1; return 1;
} }
@ -1930,27 +1935,34 @@ static void sink(char *targ, char *src)
if (act.action == SCP_SINK_DIR) { if (act.action == SCP_SINK_DIR) {
if (exists && attr != FILE_TYPE_DIRECTORY) { if (exists && attr != FILE_TYPE_DIRECTORY) {
run_err("%s: Not a directory", destfname); run_err("%s: Not a directory", destfname);
sfree(destfname);
continue; continue;
} }
if (!exists) { if (!exists) {
if (!create_directory(destfname)) { if (!create_directory(destfname)) {
run_err("%s: Cannot create directory", destfname); run_err("%s: Cannot create directory", destfname);
sfree(destfname);
continue; continue;
} }
} }
sink(destfname, NULL); sink(destfname, NULL);
/* can we set the timestamp for directories ? */ /* can we set the timestamp for directories ? */
sfree(destfname);
continue; continue;
} }
f = open_new_file(destfname, act.permissions); f = open_new_file(destfname, act.permissions);
if (f == NULL) { if (f == NULL) {
run_err("%s: Cannot create file", destfname); run_err("%s: Cannot create file", destfname);
sfree(destfname);
continue; continue;
} }
if (scp_accept_filexfer()) if (scp_accept_filexfer()) {
sfree(destfname);
close_wfile(f);
return; return;
}
stat_bytes = uint64_make(0, 0); stat_bytes = uint64_make(0, 0);
stat_starttime = time(NULL); stat_starttime = time(NULL);
@ -1994,9 +2006,11 @@ static void sink(char *targ, char *src)
set_file_times(f, act.mtime, act.atime); set_file_times(f, act.mtime, act.atime);
} }
sfree(stat_name);
close_wfile(f); close_wfile(f);
if (wrerror) { if (wrerror) {
run_err("%s: Write error", destfname); run_err("%s: Write error", destfname);
sfree(destfname);
continue; continue;
} }
(void) scp_finish_filerecv(); (void) scp_finish_filerecv();

View File

@ -922,6 +922,7 @@ int wildcard_iterate(char *filename, int (*func)(void *, char *), void *ctx)
printf("%s: canonify: %s\n", newname, fxp_error()); printf("%s: canonify: %s\n", newname, fxp_error());
ret = 0; ret = 0;
} }
sfree(newname);
matched = TRUE; matched = TRUE;
ret &= func(ctx, cname); ret &= func(ctx, cname);
sfree(cname); sfree(cname);