array pointer, _even_ if you're asking it to sort zero elements so
that in principle it should never dereference that pointer. Fix the
four instances in PSCP/PSFTP where this was previously occurring.
[originally from svn r9912]
* Now we have our filenames. Sort them by actual file
* name, and then output the longname parts.
*/
* Now we have our filenames. Sort them by actual file
* name, and then output the longname parts.
*/
- qsort(ournames, nnames, sizeof(*ournames), sftp_ls_compare);
+ if (nnames > 0)
+ qsort(ournames, nnames, sizeof(*ournames), sftp_ls_compare);
* readdirs on the same remote directory return a
* different order.
*/
* 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
/*
* If we're in restart mode, find the last filename on
* same directory, just in case two readdirs on the same
* local directory return a different order.
*/
* 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
/*
* If we're in restart mode, find the last filename on this
* Now we have our filenames. Sort them by actual file
* name, and then output the longname parts.
*/
* 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);