]> granicus.if.org Git - python/commitdiff
make 'where' Py_ssize_t
authorBenjamin Peterson <benjamin@python.org>
Thu, 6 Oct 2016 06:26:24 +0000 (23:26 -0700)
committerBenjamin Peterson <benjamin@python.org>
Thu, 6 Oct 2016 06:26:24 +0000 (23:26 -0700)
Modules/mmapmodule.c

index 297bb074ce6aed4e81519cfc41757ad5b19e1a47..0dc480599f68ef7771a1b97bdb79d278b2988cc1 100644 (file)
@@ -585,11 +585,9 @@ mmap_seek_method(mmap_object *self, PyObject *args)
     if (!PyArg_ParseTuple(args, "n|i:seek", &dist, &how))
         return NULL;
     else {
-        size_t where;
+        Py_ssize_t where;
         switch (how) {
         case 0: /* relative to start */
-            if (dist < 0)
-                goto onoutofrange;
             where = dist;
             break;
         case 1: /* relative to current position */
@@ -606,7 +604,7 @@ mmap_seek_method(mmap_object *self, PyObject *args)
             PyErr_SetString(PyExc_ValueError, "unknown seek type");
             return NULL;
         }
-        if (where > self->size)
+        if (where > self->size || where < 0)
             goto onoutofrange;
         self->pos = where;
         Py_INCREF(Py_None);