g_file_set_contents fails on mingw64 with "no error" if file size > INT_MAX
OS: windows 10
glib version: 2.74.4, build from msys2 project, mingw64
g_file_set_contents with length > INT_MAX fails with error message "no error"
Reason:
In write_to_file, write is used with chunk size up to G_MAXSIZE.
On windows, the size parameter of the write function is unsigned int and the return value (number of written bytes) is int.
Issue is solved if chunk size is limited to G_MAXINT:
s = write (fd, contents, MIN (length, G_MAXSIZE));
s = write (fd, contents, MIN (length, G_MAXINT));
In my test write returned with the correct number of written bytes but cast to int.
==> It was a negative value (==> write_to_file failed) but errno was still 0 (==> message "no error").