From 236a2443fbe32577bc4b5b9a1b58aa93f9d91de0 Mon Sep 17 00:00:00 2001 From: Raymond Hettinger Date: Sat, 15 Nov 2003 12:33:01 +0000 Subject: [PATCH] Verify heappop argument is a list. --- Modules/heapqmodule.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Modules/heapqmodule.c b/Modules/heapqmodule.c index 8a6a4f5cc13..629f516457c 100644 --- a/Modules/heapqmodule.c +++ b/Modules/heapqmodule.c @@ -119,6 +119,11 @@ heappop(PyObject *self, PyObject *heap) PyObject *lastelt, *returnitem; int n; + if (!PyList_Check(heap)) { + PyErr_SetString(PyExc_ValueError, "heap argument must be a list"); + return NULL; + } + /* # raises appropriate IndexError if heap is empty */ n = PyList_GET_SIZE(heap); if (n == 0) {