diff --git a/layout/html/table/src/nsTableRowGroupFrame.cpp b/layout/html/table/src/nsTableRowGroupFrame.cpp
index 846c43f02fc8..01f4d53da847 100644
--- a/layout/html/table/src/nsTableRowGroupFrame.cpp
+++ b/layout/html/table/src/nsTableRowGroupFrame.cpp
@@ -1767,6 +1767,9 @@ nsTableRowGroupFrame::GetLine(PRInt32 aLineNumber, nsIFrame** aFirstFrameOnLine,
// not gonna touch aLineBounds right now
CellData* firstCellData = cellMap->GetCellAt(aLineNumber, 0);
+ if(!firstCellData)
+ return NS_ERROR_FAILURE;
+
*aFirstFrameOnLine = (nsIFrame*)firstCellData->GetCellFrame();
if(!(*aFirstFrameOnLine))
{
diff --git a/layout/tables/nsTableRowGroupFrame.cpp b/layout/tables/nsTableRowGroupFrame.cpp
index 846c43f02fc8..01f4d53da847 100644
--- a/layout/tables/nsTableRowGroupFrame.cpp
+++ b/layout/tables/nsTableRowGroupFrame.cpp
@@ -1767,6 +1767,9 @@ nsTableRowGroupFrame::GetLine(PRInt32 aLineNumber, nsIFrame** aFirstFrameOnLine,
// not gonna touch aLineBounds right now
CellData* firstCellData = cellMap->GetCellAt(aLineNumber, 0);
+ if(!firstCellData)
+ return NS_ERROR_FAILURE;
+
*aFirstFrameOnLine = (nsIFrame*)firstCellData->GetCellFrame();
if(!(*aFirstFrameOnLine))
{