From 56a39df6350455445374edf88c94e3af668faa44 Mon Sep 17 00:00:00 2001 From: Virgil Dupras Date: Wed, 14 Jul 2010 09:36:35 +0200 Subject: [PATCH] [#96 state:fixed] Fixed a hard crash on calling get_blocks() with an empty path. --- core_pe/matchbase.py | 2 +- core_pe/modules/block_osx.m | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/core_pe/matchbase.py b/core_pe/matchbase.py index 4808dcd9..99680a44 100644 --- a/core_pe/matchbase.py +++ b/core_pe/matchbase.py @@ -40,7 +40,7 @@ def prepare_pictures(pictures, cache_path, j=job.nulljob): blocks = picture.get_blocks(BLOCK_COUNT_PER_SIDE) cache[picture.unicode_path] = blocks prepared.append(picture) - except IOError as e: + except (IOError, ValueError) as e: logging.warning(unicode(e)) except MemoryError: logging.warning(u'Ran out of memory while reading %s of size %d' % (picture.unicode_path, picture.size)) diff --git a/core_pe/modules/block_osx.m b/core_pe/modules/block_osx.m index 26cc64b9..e4609a02 100644 --- a/core_pe/modules/block_osx.m +++ b/core_pe/modules/block_osx.m @@ -158,6 +158,11 @@ static PyObject* block_osx_getblocks(PyObject *self, PyObject *args) return NULL; } + if (PySequence_Length(path) == 0) { + PyErr_SetString(PyExc_ValueError, "empty path"); + return NULL; + } + image_path = pystring2cfstring(path); if (image_path == NULL) { return PyErr_NoMemory();