diff --git a/binutils/stabs.c b/binutils/stabs.c
index 81068a4bf7c..27d49376b97 100644
--- a/binutils/stabs.c
+++ b/binutils/stabs.c
@@ -1293,6 +1293,12 @@ parse_stab_type (void *                dhandle,
 	}
     }
 
+  if (*pp >= p_end)
+    {
+      bad_stab (orig);
+      return DEBUG_TYPE_NULL;
+    }
+
   descriptor = **pp;
   ++*pp;
 
@@ -3219,11 +3225,7 @@ parse_stab_array_type (void *dhandle,
     {
       index_type = debug_find_named_type (dhandle, "int");
       if (index_type == DEBUG_TYPE_NULL)
-	{
-	  index_type = debug_make_int_type (dhandle, 4, false);
-	  if (index_type == DEBUG_TYPE_NULL)
-	    return DEBUG_TYPE_NULL;
-	}
+	index_type = debug_make_int_type (dhandle, 4, false);
       *pp = p;
     }
   else
@@ -3231,6 +3233,8 @@ parse_stab_array_type (void *dhandle,
       index_type = parse_stab_type (dhandle, info, (const char *) NULL, pp,
 				    (debug_type **) NULL, p_end);
     }
+  if (index_type == DEBUG_TYPE_NULL)
+    return DEBUG_TYPE_NULL;
 
   if (**pp != ';')
     {
