Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
libobs: Assure large enough buffer in dstr_from_cfstring
Per the documentation of CFStringGetCString, the buffer provided must be large enough not just for the string itself, but also for a NUL terminator. This space for the NUL terminator is currently ignored, and we just get lucky that CFStringGetMaximumSizeForEncoding often dramatically overestimates the space required. However, it is possible to actually hit the maximum with the string itself (for example by using strings that contain exclusively Chinese characters such as "我"), in which case the conversion fails. Adding the extra byte for the NUL terminator fixes this. At this point, we can also safely assert that our max_size is larger than zero, silencing a clang analyzer warning that now is no longer valid.
- Loading branch information