diff --git a/MediaBrowser.MediaEncoding/Encoder/ApplePlatformHelper.cs b/MediaBrowser.MediaEncoding/Encoder/ApplePlatformHelper.cs index 8cae6a238d..baea0df8cc 100644 --- a/MediaBrowser.MediaEncoding/Encoder/ApplePlatformHelper.cs +++ b/MediaBrowser.MediaEncoding/Encoder/ApplePlatformHelper.cs @@ -37,7 +37,12 @@ public static partial class ApplePlatformHelper throw new NotSupportedException($"Failed to get sysctl value for {name} with error {osStatus}"); } - ReadOnlySpan data = buffer.AsSpan()[..(int)length]; + if (length < 1) + { + return string.Empty; + } + + ReadOnlySpan data = buffer.AsSpan()[..(int)(length - 1)]; return Encoding.UTF8.GetString(data); } finally