X-Git-Url: https://git.distorted.org.uk/~mdw/sgt/putty/blobdiff_plain/feae2dfc998c2e9433cb88da64cab0fdc7e5896c..fb73b28d8dd9758d692fc368fd2bb0490b5e3bcc:/psftp.c diff --git a/psftp.c b/psftp.c index b6a2bb58..65d0dc50 100644 --- a/psftp.c +++ b/psftp.c @@ -327,7 +327,8 @@ int sftp_get_file(char *fname, char *outfname, int recurse, int restart) * readdirs on the same remote directory return a * different order. */ - qsort(ournames, nnames, sizeof(*ournames), sftp_name_compare); + if (nnames > 0) + qsort(ournames, nnames, sizeof(*ournames), sftp_name_compare); /* * If we're in restart mode, find the last filename on @@ -570,7 +571,8 @@ int sftp_put_file(char *fname, char *outfname, int recurse, int restart) * same directory, just in case two readdirs on the same * local directory return a different order. */ - qsort(ournames, nnames, sizeof(*ournames), bare_name_compare); + if (nnames > 0) + qsort(ournames, nnames, sizeof(*ournames), bare_name_compare); /* * If we're in restart mode, find the last filename on this @@ -1093,7 +1095,8 @@ int sftp_cmd_ls(struct sftp_command *cmd) * Now we have our filenames. Sort them by actual file * name, and then output the longname parts. */ - qsort(ournames, nnames, sizeof(*ournames), sftp_name_compare); + if (nnames > 0) + qsort(ournames, nnames, sizeof(*ournames), sftp_name_compare); /* * And print them.