When the name of a non-existent file is given as the argument to a 'get' or 'put' command, sftp(1) fails to interpret correctly the result of the glob(3) invocation. glob(3) does not return an error (a non-zero exit), yet it does not return any meaningful file names, either, so process_get() and process_put()'s attempts to access the gl_pathv[] array fail miserably. A trivial patch is posted in the audit-trail of the FreeBSD problem report referenced by the URL above.
Are you sure it is not your glob() implementation that is incorrect here? sftp relies on glob to return non-zero (i.e. GLOB_NOMATCH) when no files are matched. This works correctly on Linux, Solaris and OpenBSD.
Resolution: FreeBSD's glob function doesn't support GLOB_NOMATCH (which AFAIK is a POSIX requirement). FreeBSD will patch their shipped version of sftp for the upcoming release and will implement GLOB_NOMATCH in future. The URL attached to this bug includes the patch they intend to apply (it also contains a GLOB_NOMATCH patch)
Mass change of RESOLVED bugs to CLOSED