--- a/2DAEdit.cpp
+++ b/2DAEdit.cpp
@@ -623,7 +623,7 @@
   POSITION pos;
   int i;
 
-  if(m_item<0) m_item=the_2da.rows;
+  if(m_item<0 || m_item>the_2da.rows) m_item=the_2da.rows;
   tmpstr.Format("Row%d",m_item);
   the_2da.AddRow(m_item, tmpstr, the_2da.defvalue);
   pos=the_2da.data->FindIndex(m_item);