diff --git a/content/html/content/src/nsHTMLTableElement.cpp b/content/html/content/src/nsHTMLTableElement.cpp index 6403a5e167cc..c79e45fb456a 100644 --- a/content/html/content/src/nsHTMLTableElement.cpp +++ b/content/html/content/src/nsHTMLTableElement.cpp @@ -797,8 +797,9 @@ nsHTMLTableElement::InsertRow(PRInt32 aIndex, nsIDOMHTMLElement** aValue) nsCOMPtr newRowNode(do_QueryInterface(newRow)); nsCOMPtr retChild; - // the index is greater than the number of rows, so just append - if ((0 <= aIndex) && (PRInt32(rowCount) <= aIndex)) { + // If index is -1 or equal to the number of rows, the new row + // is appended. + if (aIndex == -1 || PRUint32(aIndex) == rowCount) { rv = parent->AppendChild(newRowNode, getter_AddRefs(retChild)); } else