瀏覽代碼

AK: String::contains() should say no if needle or haystack is null

Andreas Kling 5 年之前
父節點
當前提交
c993c7e3dc
共有 1 個文件被更改,包括 2 次插入0 次删除
  1. 2 0
      AK/String.cpp

+ 2 - 0
AK/String.cpp

@@ -312,6 +312,8 @@ bool String::matches(const StringView& mask, CaseSensitivity case_sensitivity) c
 
 bool String::contains(const String& needle) const
 {
+    if (is_null() || needle.is_null())
+        return false;
     return strstr(characters(), needle.characters());
 }