#3305: self->stream can be NULL.
This commit is contained in:
parent
86cbf81b47
commit
b9b68ae7a5
|
@ -8,6 +8,7 @@ from test import test_support
|
|||
from test import test_multibytecodec_support
|
||||
from test.test_support import TESTFN
|
||||
import unittest, StringIO, codecs, sys, os
|
||||
import _multibytecodec
|
||||
|
||||
ALL_CJKENCODINGS = [
|
||||
# _codecs_cn
|
||||
|
@ -53,6 +54,14 @@ class Test_MultibyteCodec(unittest.TestCase):
|
|||
finally:
|
||||
os.unlink(TESTFN)
|
||||
|
||||
def test_init_segfault(self):
|
||||
# bug #3305: this used to segfault
|
||||
self.assertRaises(AttributeError,
|
||||
_multibytecodec.MultibyteStreamReader, None)
|
||||
self.assertRaises(AttributeError,
|
||||
_multibytecodec.MultibyteStreamWriter, None)
|
||||
|
||||
|
||||
class Test_IncrementalEncoder(unittest.TestCase):
|
||||
|
||||
def test_stateless(self):
|
||||
|
|
|
@ -1484,7 +1484,7 @@ mbstreamreader_dealloc(MultibyteStreamReaderObject *self)
|
|||
{
|
||||
PyObject_GC_UnTrack(self);
|
||||
ERROR_DECREF(self->errors);
|
||||
Py_DECREF(self->stream);
|
||||
Py_XDECREF(self->stream);
|
||||
Py_TYPE(self)->tp_free(self);
|
||||
}
|
||||
|
||||
|
@ -1686,7 +1686,7 @@ mbstreamwriter_dealloc(MultibyteStreamWriterObject *self)
|
|||
{
|
||||
PyObject_GC_UnTrack(self);
|
||||
ERROR_DECREF(self->errors);
|
||||
Py_DECREF(self->stream);
|
||||
Py_XDECREF(self->stream);
|
||||
Py_TYPE(self)->tp_free(self);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue