Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-cw
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-cw
Commits
85566822
Commit
85566822
authored
Jun 12, 2020
by
Piotr Caban
Committed by
Alexandre Julliard
Jun 12, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
msvcrt: Reset buffer in fflush on error.
Signed-off-by:
Piotr Caban
<
piotr@codeweavers.com
>
Signed-off-by:
Alexandre Julliard
<
julliard@winehq.org
>
parent
1e833e58
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
6 deletions
+23
-6
file.c
dlls/msvcrt/file.c
+6
-5
file.c
dlls/msvcrt/tests/file.c
+17
-1
No files found.
dlls/msvcrt/file.c
View file @
85566822
...
...
@@ -656,21 +656,22 @@ void msvcrt_init_io(void)
/* INTERNAL: Flush stdio file buffer */
static
int
msvcrt_flush_buffer
(
MSVCRT_FILE
*
file
)
{
int
ret
=
0
;
if
((
file
->
_flag
&
(
MSVCRT__IOREAD
|
MSVCRT__IOWRT
))
==
MSVCRT__IOWRT
&&
file
->
_flag
&
(
MSVCRT__IOMYBUF
|
MSVCRT__USERBUF
))
{
int
cnt
=
file
->
_ptr
-
file
->
_base
;
if
(
cnt
>
0
&&
MSVCRT__write
(
file
->
_file
,
file
->
_base
,
cnt
)
!=
cnt
)
{
file
->
_flag
|=
MSVCRT__IOERR
;
return
MSVCRT_EOF
;
}
if
(
file
->
_flag
&
MSVCRT__IORW
)
ret
=
MSVCRT_EOF
;
}
else
if
(
file
->
_flag
&
MSVCRT__IORW
)
{
file
->
_flag
&=
~
MSVCRT__IOWRT
;
}
}
file
->
_ptr
=
file
->
_base
;
file
->
_cnt
=
0
;
return
0
;
return
ret
;
}
/*********************************************************************
...
...
dlls/msvcrt/tests/file.c
View file @
85566822
...
...
@@ -687,7 +687,7 @@ static void test_fflush( void )
char
buf1
[
16
],
buf2
[
24
];
char
*
tempf
;
FILE
*
tempfh
;
int
ret
;
int
ret
,
fd
;
tempf
=
_tempnam
(
"."
,
"wne"
);
...
...
@@ -728,7 +728,23 @@ static void test_fflush( void )
ok
(
memcmp
(
buf1
,
buf2
,
sizeof
(
buf1
))
==
0
,
"Got unexpected data (%c)
\n
"
,
buf2
[
0
]);
fclose
(
tempfh
);
unlink
(
tempf
);
/* test flush failure */
tempfh
=
fopen
(
tempf
,
"wb"
);
ok
(
tempfh
!=
NULL
,
"Can't open test file.
\n
"
);
fwrite
(
obuf
,
1
,
sizeof
(
obuf
),
tempfh
);
fd
=
tempfh
->
_file
;
tempfh
->
_file
=
-
1
;
ok
(
tempfh
->
_ptr
-
tempfh
->
_base
,
"buffer is empty
\n
"
);
ret
=
fflush
(
tempfh
);
ok
(
ret
==
EOF
,
"expected EOF, got %d
\n
"
,
ret
);
ok
(
!
(
tempfh
->
_ptr
-
tempfh
->
_base
),
"buffer should be empty
\n
"
);
ok
(
!
tempfh
->
_cnt
,
"tempfh->_cnt = %d
\n
"
,
tempfh
->
_cnt
);
tempfh
->
_file
=
fd
;
fclose
(
tempfh
);
unlink
(
tempf
);
free
(
tempf
);
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment