changeset 576:64150963f567

win: fix fmemopen polyfill https://github.com/Arryboom/fmemopen_windows/issues/4
author David Demelier <markand@malikania.fr>
date Sat, 11 Mar 2023 11:04:11 +0100
parents d682f9142c52
children f937857336f3
files libmlk-util/mlk/util/fmemopen.c
diffstat 1 files changed, 5 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/libmlk-util/mlk/util/fmemopen.c	Fri Mar 10 19:28:01 2023 +0100
+++ b/libmlk-util/mlk/util/fmemopen.c	Sat Mar 11 11:04:11 2023 +0100
@@ -36,6 +36,8 @@
 FILE *
 mlk_util_fmemopen(void *buf, size_t size, const char *mode)
 {
+	(void)mode;
+
 	char temppath[MAX_PATH + 1], filename[MAX_PATH + 1];
 	FILE *fp;
 	int fd, flags;
@@ -55,7 +57,9 @@
 		return NULL;
 	if (_sopen_s(&fd, filename, flags, _SH_DENYRW, _S_IREAD | _S_IWRITE) < 0)
 		return NULL;
-	if (!(fp = _fdopen(fd, mode))) {
+
+	/* The mode must be ignored because this polyfill requires push back */
+	if (!(fp = _fdopen(fd, "w+"))) {
 		_close(fd);
 		return NULL;
 	}