osdep/io: fix fdopen mode flag
In both C11 standard and Microsoft documentation, '+' must be placed immediately after mode, so placing 'b' between them is incorrect.
This commit is contained in:
1 parent
f1a42eff01
commit
1f150567ac
1 file changed
+5
-1
+5
-1
@@ -105,7 +105,11 @@ FILE *mp_fopen(const char *filename, const char *mode)
|
||||
return NULL;
|
||||
|
||||
// Add 'b' to the mode so the CRT knows the file is opened in binary mode
|
||||
char bmode[] = { mode[0], 'b', rwmode == O_RDWR ? '+' : '\0', '\0' };
|
||||
char bmode[] = { mode[0], '\0', '\0', '\0' };
|
||||
int idx = 1;
|
||||
if (rwmode == O_RDWR)
|
||||
bmode[idx++] = '+';
|
||||
bmode[idx++] = 'b';
|
||||
FILE *fp = fdopen(fd, bmode);
|
||||
if (!fp) {
|
||||
close(fd);
|
||||
|
||||
Reference in new issue
Block a user