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:
parent
815b03eeb7
commit
35c88d99e3
1 changed files with 2 additions and 2 deletions
|
|
@ -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()
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue