fix: return empty SeString if ptr == null

This commit is contained in:
goat 2021-08-28 21:27:20 +02:00
parent fc9ef07005
commit 49345847a5
No known key found for this signature in database
GPG key ID: F18F057873895461

View file

@ -61,6 +61,11 @@ namespace Dalamud.Game.Text.SeStringHandling
UIForegroundPayload.UIForegroundOff, UIForegroundPayload.UIForegroundOff,
}); });
/// <summary>
/// Gets an empty SeString.
/// </summary>
public static SeString Empty => new();
/// <summary> /// <summary>
/// Gets the ordered list of payloads included in this SeString. /// Gets the ordered list of payloads included in this SeString.
/// </summary> /// </summary>
@ -105,6 +110,9 @@ namespace Dalamud.Game.Text.SeStringHandling
/// <returns>An SeString containing parsed Payload objects for each payload in the data.</returns> /// <returns>An SeString containing parsed Payload objects for each payload in the data.</returns>
public static unsafe SeString Parse(byte* ptr, int len) public static unsafe SeString Parse(byte* ptr, int len)
{ {
if (ptr == null)
return Empty;
var payloads = new List<Payload>(); var payloads = new List<Payload>();
using (var stream = new UnmanagedMemoryStream(ptr, len)) using (var stream = new UnmanagedMemoryStream(ptr, len))