diff options
author | Nadeem Vawda <nadeem.vawda@gmail.com> | 2013-10-28 21:41:24 +0100 |
---|---|---|
committer | Nadeem Vawda <nadeem.vawda@gmail.com> | 2013-10-28 21:41:24 +0100 |
commit | acf010d6b83e6ee4bc916a61b04938f2f4205810 (patch) | |
tree | 20104eff0d9561d62fc9f538a7882d7b98e00ac1 /Python/thread.c | |
parent | 284a788ebc97e88858f9299669470438dcf0ebfb (diff) | |
parent | c3408df66ec4dbebcbbfc283cebd9736d97f5f1c (diff) | |
download | cpython-acf010d6b83e6ee4bc916a61b04938f2f4205810.tar.gz |
#19395: Raise exception when pickling a (BZ2|LZMA)(Compressor|Decompressor).
The underlying C libraries provide no mechanism for serializing compressor and
decompressor objects, so actually pickling these classes is impractical.
Previously, these objects would be pickled without error, but attempting to use
a deserialized instance would segfault the interpreter.
Diffstat (limited to 'Python/thread.c')
-rw-r--r-- | Python/thread.c | 18 |
1 files changed, 8 insertions, 10 deletions
diff --git a/Python/thread.c b/Python/thread.c index e55d34244e..8540942e28 100644 --- a/Python/thread.c +++ b/Python/thread.c @@ -91,10 +91,6 @@ static size_t _pythread_stacksize = 0; #include "thread_nt.h" #endif -#ifdef OS2_THREADS -#define PYTHREAD_NAME "os2" -#include "thread_os2.h" -#endif /* #ifdef FOOBAR_THREADS @@ -235,7 +231,7 @@ find_key(int key, void *value) assert(p == NULL); goto Done; } - p = (struct key *)malloc(sizeof(struct key)); + p = (struct key *)PyMem_RawMalloc(sizeof(struct key)); if (p != NULL) { p->id = id; p->key = key; @@ -274,7 +270,7 @@ PyThread_delete_key(int key) while ((p = *q) != NULL) { if (p->key == key) { *q = p->next; - free((void *)p); + PyMem_RawFree((void *)p); /* NB This does *not* free p->value! */ } else @@ -328,7 +324,7 @@ PyThread_delete_key_value(int key) while ((p = *q) != NULL) { if (p->key == key && p->id == id) { *q = p->next; - free((void *)p); + PyMem_RawFree((void *)p); /* NB This does *not* free p->value! */ break; } @@ -361,7 +357,7 @@ PyThread_ReInitTLS(void) while ((p = *q) != NULL) { if (p->id != id) { *q = p->next; - free((void *)p); + PyMem_RawFree((void *)p); /* NB This does *not* free p->value! */ } else @@ -403,8 +399,10 @@ PyThread_GetInfo(void) int len; #endif - if (ThreadInfoType.tp_name == 0) - PyStructSequence_InitType(&ThreadInfoType, &threadinfo_desc); + if (ThreadInfoType.tp_name == 0) { + if (PyStructSequence_InitType2(&ThreadInfoType, &threadinfo_desc) < 0) + return NULL; + } threadinfo = PyStructSequence_New(&ThreadInfoType); if (threadinfo == NULL) |