Merge branch '3176_sftpfs_view_file_segfault'

* 3176_sftpfs_view_file_segfault:
  Ticket #3176: sftpfs: fix segfault when trying to view a file.
This commit is contained in:
Andrew Borodin 2014-02-28 09:37:47 +04:00
commit e68bf2d473

View File

@ -60,12 +60,16 @@ static void
sftpfs_reopen (vfs_file_handler_t * file_handler, GError ** error)
{
sftpfs_file_handler_data_t *file_handler_data;
int flags;
mode_t mode;
file_handler_data = (sftpfs_file_handler_data_t *) file_handler->data;
flags = file_handler_data->flags;
mode = file_handler_data->mode;
sftpfs_close_file (file_handler, error);
if (error == NULL || *error == NULL)
sftpfs_open_file (file_handler, file_handler_data->flags, file_handler_data->mode, error);
sftpfs_open_file (file_handler, flags, mode, error);
}
/* --------------------------------------------------------------------------------------------- */
@ -361,8 +365,6 @@ sftpfs_lseek (vfs_file_handler_t * file_handler, off_t offset, int whence, GErro
{
sftpfs_file_handler_data_t *file_handler_data;
file_handler_data = (sftpfs_file_handler_data_t *) file_handler->data;
switch (whence)
{
case SEEK_SET:
@ -392,6 +394,8 @@ sftpfs_lseek (vfs_file_handler_t * file_handler, off_t offset, int whence, GErro
break;
}
file_handler_data = (sftpfs_file_handler_data_t *) file_handler->data;
libssh2_sftp_seek64 (file_handler_data->handle, file_handler->pos);
file_handler->pos = (off_t) libssh2_sftp_tell64 (file_handler_data->handle);