Skip to content

Commit

Permalink
Merge branch '3176_sftpfs_view_file_segfault'
Browse files Browse the repository at this point in the history
* 3176_sftpfs_view_file_segfault:
  Ticket #3176: sftpfs: fix segfault when trying to view a file.
  • Loading branch information
aborodin committed Feb 28, 2014
2 parents 9bbc510 + cd44dc5 commit e68bf2d
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/vfs/sftpfs/file.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

/* --------------------------------------------------------------------------------------------- */
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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);

Expand Down

0 comments on commit e68bf2d

Please sign in to comment.