diff --git a/typo3/sysext/frontend/Classes/ContentObject/Menu/AbstractMenuContentObject.php b/typo3/sysext/frontend/Classes/ContentObject/Menu/AbstractMenuContentObject.php
index db188037ebfb6c1f22d865321a07274156c149d9..d1cb436b96256e901f269c565d28db8d342fc206 100644
--- a/typo3/sysext/frontend/Classes/ContentObject/Menu/AbstractMenuContentObject.php
+++ b/typo3/sysext/frontend/Classes/ContentObject/Menu/AbstractMenuContentObject.php
@@ -992,7 +992,7 @@ abstract class AbstractMenuContentObject
                 $recArr['up'] = $this->sys_page->getPage($value_rec['pid']);
             }
             // If the 'up' item was NOT level 0 in rootline...
-            if ($recArr['up']['pid'] && $value_rec['pid'] != $this->tmpl->rootLine[0]['uid']) {
+            if (($recArr['up']['pid'] ?? 0) && $value_rec['pid'] != $this->tmpl->rootLine[0]['uid']) {
                 // The page record of "index".
                 $recArr['index'] = $this->sys_page->getPage($recArr['up']['pid']);
             }