fix: make win32's drang_fs_get_cwd only fail with ENOMEM when the buffer is not null, and correctly exclude the null terminator when the buffer size is too small

This commit is contained in:
MechSlayer 2025-09-11 06:19:50 +02:00
parent 815b03eeb7
commit 35c88d99e3

View file

@ -132,10 +132,10 @@ int drang_fs_get_cwd(char *buffer, size_t size, size_t *out_size)
}
if (out_size) {
*out_size = length;
*out_size = length > size ? length - 1 : length; // Exclude null terminator if the buffer is too small
}
DRANG_CHECK(length < size, DRANG_ENOMEM);
DRANG_CHECK(buffer != NULL && length < size, DRANG_ENOMEM);
DRANG_END_TRY_IGNORE()
}