diff options
| author | Michael Vogt <michael.vogt@ubuntu.com> | 2009-03-03 21:21:05 +0100 |
|---|---|---|
| committer | Michael Vogt <michael.vogt@ubuntu.com> | 2009-03-03 21:21:05 +0100 |
| commit | 2342bc7c05da5589f166496fe1112b249598648f (patch) | |
| tree | 6ccb3681e9f7328cdb70823fa9183da2062d713e /python | |
| parent | 46c29108ea76d1ca336042be99bbe11e8e5061b8 (diff) | |
| parent | 754744630ff6228029cd025074dc0cfe3de08495 (diff) | |
| download | python-apt-2342bc7c05da5589f166496fe1112b249598648f.tar.gz | |
* python/cache.cc, tests/getcache_mem_corruption.py:
- test if progress objects have the right methods
and raise error if not (thanks to Emanuele Rocca)
closes: #497049
Diffstat (limited to 'python')
| -rw-r--r-- | python/cache.cc | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/python/cache.cc b/python/cache.cc index 1c59bece..0c59f561 100644 --- a/python/cache.cc +++ b/python/cache.cc @@ -936,14 +936,26 @@ PyObject *TmpGetCache(PyObject *Self,PyObject *Args) pkgCacheFile *Cache = new pkgCacheFile(); if(pyCallbackInst != 0) { + // sanity check for the progress object, see #497049 + if (PyObject_HasAttrString(pyCallbackInst, "done") != true) { + PyErr_SetString(PyExc_ValueError, + "OpProgress object must implement done()"); + return 0; + } + if (PyObject_HasAttrString(pyCallbackInst, "update") != true) { + PyErr_SetString(PyExc_ValueError, + "OpProgress object must implement update()"); + return 0; + } PyOpProgress progress; progress.setCallbackInst(pyCallbackInst); if (Cache->Open(progress,false) == false) - return HandleErrors(); - } else { + return HandleErrors(); + } + else { OpTextProgress Prog; if (Cache->Open(Prog,false) == false) - return HandleErrors(); + return HandleErrors(); } CppOwnedPyObject<pkgCacheFile*> *CacheFileObj = |
