From d300a5a45b73c7d1fdb631a9d93db66c70903486 Mon Sep 17 00:00:00 2001 From: Mary Date: Wed, 12 Jan 2022 17:43:00 +0100 Subject: sfdnsres: Fix serialization issues (#2992) * sfdnsres: Fix serialization issues Fix a crash on Monster Hunter Rise * Address gdkchan's comments * Address gdkchan's comments --- Ryujinx.HLE/Utilities/StringUtils.cs | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'Ryujinx.HLE/Utilities') diff --git a/Ryujinx.HLE/Utilities/StringUtils.cs b/Ryujinx.HLE/Utilities/StringUtils.cs index 2b7cbffe..3027139b 100644 --- a/Ryujinx.HLE/Utilities/StringUtils.cs +++ b/Ryujinx.HLE/Utilities/StringUtils.cs @@ -60,6 +60,18 @@ namespace Ryujinx.HLE.Utilities return output; } + public static string ReadUtf8String(ReadOnlySpan data, out int dataRead) + { + dataRead = data.IndexOf((byte)0) + 1; + + if (dataRead <= 1) + { + return string.Empty; + } + + return Encoding.UTF8.GetString(data[..dataRead]); + } + public static string ReadUtf8String(ServiceCtx context, int index = 0) { ulong position = context.Request.PtrBuff[index].Position; -- cgit v1.2.3