mirror of
https://github.com/obsproject/obs-studio.git
synced 2026-08-30 17:58:37 +08:00
71775e3619
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.