stdcxx-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Farid Zaripov (JIRA)" <j...@apache.org>
Subject [jira] Assigned: (STDCXX-969) std::basic_filebuf<>: sync() after close() calls __rw_fseek() on closed file
Date Wed, 25 Jun 2008 05:24:45 GMT

     [ https://issues.apache.org/jira/browse/STDCXX-969?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Farid Zaripov reassigned STDCXX-969:
------------------------------------

    Assignee: Farid Zaripov

> std::basic_filebuf<>: sync() after close() calls __rw_fseek() on closed file
> ----------------------------------------------------------------------------
>
>                 Key: STDCXX-969
>                 URL: https://issues.apache.org/jira/browse/STDCXX-969
>             Project: C++ Standard Library
>          Issue Type: Bug
>          Components: 27. Input/Output
>    Affects Versions: 4.1.2, 4.1.3, 4.1.4, 4.2.0, 4.2.1
>         Environment: All
>            Reporter: Farid Zaripov
>            Assignee: Farid Zaripov
>             Fix For: 4.2.2
>
>   Original Estimate: 1h
>  Remaining Estimate: 1h
>
> {code:title=test.cpp}
> #include <fstream>
> int main (int argc, char* argv[])
> {
>     std::ifstream fs (argv [0], std::ios::binary);
>     char c;
>     fs.get (c);
>     fs.close ();
>     fs.sync ();
>     return 0;
> }
> {code}
> In the test above the fs.sync() calls __rw_fseek(0, ...), that leads to lseek (-1, ...).
> The proposed patch:
> {code:title=fstream.cc.diff}
> Index: include/fstream.cc
> ===================================================================
> --- include/fstream.cc	(revision 667432)
> +++ include/fstream.cc	(working copy)
> @@ -106,6 +106,8 @@
>              _C_file    = 0;
>              _C_cur_pos = _C_beg_pos = pos_type (off_type (-1));
>  
> +            this->setg(0, 0, 0);
> +            this->setp(0, 0);
>          }
>  
>          // rethrow the caught exception
> @@ -119,6 +121,9 @@
>          // zero out the file pointer except when detaching fd
>          _C_file    = 0;
>          _C_cur_pos = _C_beg_pos = pos_type (off_type (-1));
> +
> +        this->setg(0, 0, 0);
> +        this->setp(0, 0);
>      }
>  
>      return __retval;
> {code}

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


Mime
View raw message