diff --git a/Source/DrangPlatform/Source/win32/fs/dir.c b/Source/DrangPlatform/Source/win32/fs/dir.c index 1e10dcf..2a3fcfb 100644 --- a/Source/DrangPlatform/Source/win32/fs/dir.c +++ b/Source/DrangPlatform/Source/win32/fs/dir.c @@ -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() }