From c6947bdf65a766d7ad9f232101d3b64bc94e8801 Mon Sep 17 00:00:00 2001 From: Matt Cai Date: Fri, 14 Sep 2018 17:06:05 +0800 Subject: [PATCH] fix a crash [NSString stringWithUTF8String:NULL] cause crash --- OCGumbo/OCGumbo.m | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/OCGumbo/OCGumbo.m b/OCGumbo/OCGumbo.m index 5a9f973..52b0a56 100644 --- a/OCGumbo/OCGumbo.m +++ b/OCGumbo/OCGumbo.m @@ -209,7 +209,8 @@ - (OCGumboAttribute *)getAttributeNode:(NSString *)name { } - (NSString *)getAttribute:(NSString *)name { - return @(oc_gumbo_get_attribute(_gumboNode, [name UTF8String])); + const char *text = oc_gumbo_get_attribute(_gumboNode, [name UTF8String]); + return text ? @(text) : nil; } @end