OBS Studio - Free and open source software for live streaming and screen recording
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.
G
gxalpha committed
71775e36190b248c1ae08c36a4316f33c83bcccd
Parent: 42670ab
Committed by Ryan Foster <ryan@obsproject.com>
on 10/4/2024, 5:36:09 PM