Index: lib/matplotlib/colors.py
===================================================================
--- lib/matplotlib/colors.py	(revision 6254)
+++ lib/matplotlib/colors.py	(working copy)
@@ -455,7 +455,8 @@
             mask_bad = ma.getmask(xma)
         if xa.dtype.char in np.typecodes['Float']:
             np.putmask(xa, xa==1.0, 0.9999999) #Treat 1.0 as slightly less than 1.
-            xa = (xa * self.N).astype(int)
+            np.clip(xa * self.N, -1, self.N, out=xa)
+            xa = xa.astype(int)
         # Set the over-range indices before the under-range;
         # otherwise the under-range values get converted to over-range.
         np.putmask(xa, xa>self.N-1, self._i_over)
