diff options
author | German M. Bravo <german.mb@deipi.com> | 2013-08-14 14:02:58 -0500 |
---|---|---|
committer | German M. Bravo <german.mb@deipi.com> | 2013-08-16 09:40:08 -0500 |
commit | 47e804b3913c3b2cd4f0bb3a588b7189e586b894 (patch) | |
tree | 6c6138230416b4365c72cc491246c6f28aea6509 | |
parent | e60ec23930a661044cb5029f82f3aa740fbbe874 (diff) | |
download | pyscss-47e804b3913c3b2cd4f0bb3a588b7189e586b894.tar.gz |
Fixed bug where passing no restrictions to the toke() method, it crashed
-rw-r--r-- | scss/src/_speedups.c | 26 |
1 files changed, 14 insertions, 12 deletions
diff --git a/scss/src/_speedups.c b/scss/src/_speedups.c index f70543c..b4b990c 100644 --- a/scss/src/_speedups.c +++ b/scss/src/_speedups.c @@ -168,24 +168,26 @@ scss_Scanner_token(scss_Scanner *self, PyObject *args) Token *p_token; int token_num; - PyObject *restrictions; + PyObject *restrictions = NULL; Pattern *_restrictions = NULL; int restrictions_sz = 0; if (self->scanner != NULL) { if (PyArg_ParseTuple(args, "i|O", &token_num, &restrictions)) { - size = PySequence_Size(restrictions); - if (size != -1) { - _restrictions = PyMem_New(Pattern, size); - iter = PyObject_GetIter(restrictions); - while ((item = PyIter_Next(iter))) { - if (PyString_Check(item)) { - _restrictions[restrictions_sz].tok = PyString_AsString(item); - _restrictions[restrictions_sz].expr = NULL; - restrictions_sz++; + if (restrictions != NULL) { + size = PySequence_Size(restrictions); + if (size != -1) { + _restrictions = PyMem_New(Pattern, size); + iter = PyObject_GetIter(restrictions); + while ((item = PyIter_Next(iter))) { + if (PyString_Check(item)) { + _restrictions[restrictions_sz].tok = PyString_AsString(item); + _restrictions[restrictions_sz].expr = NULL; + restrictions_sz++; + } + Py_DECREF(item); } - Py_DECREF(item); + Py_DECREF(iter); } - Py_DECREF(iter); } p_token = Scanner_token(self->scanner, token_num, _restrictions, restrictions_sz); |