Use "if" check to avoid crash 83/318783/3
authorfr.fang <fr.fang@samsung.com>
Tue, 8 Oct 2024 16:39:50 +0000 (00:39 +0800)
committerBot Blink <blinkbot@samsung.com>
Tue, 8 Oct 2024 09:51:22 +0000 (09:51 +0000)
Use "if" instead of "CHECK" to avoid crash at MayHaveHTMLLabel

Change-Id: Ia30df38b994ccf418967fc31f0ceb0dbadfda65d
Signed-off-by: fr.fang <fr.fang@samsung.com>
third_party/blink/renderer/modules/accessibility/ax_object_cache_impl.cc

index ced89edd3e567f660bc7ce2219bd212ed61836ae..3798d92b6bf9e7ce0cd98e7323c5ebbddfff5af2 100644 (file)
@@ -3352,10 +3352,15 @@ void AXObjectCacheImpl::ValidatedAriaOwnedChildren(
 }
 
 bool AXObjectCacheImpl::MayHaveHTMLLabel(const HTMLElement& elem) {
-  CHECK(elem.GetDocument().Lifecycle().GetState() >=
-        DocumentLifecycle::kLayoutClean)
-      << "Unclean document at lifecycle " << elem.GetDocument().ToString();
-  CHECK(relation_cache_);
+  if (!(elem.GetDocument().Lifecycle().GetState() >=
+        DocumentLifecycle::kLayoutClean)) {
+    LOG(ERROR) << "Unclean document at lifecycle "
+               << elem.GetDocument().ToString();
+    return false;
+  }
+
+  if (!relation_cache_)
+    return false;
 
   // Return false if this type of element will not accept a <label for> label.
   if (!elem.IsLabelable())