reviewed by Brett Cannon.
Core and Builtins
-----------------
+- Issue 3774: Added a few more checks in PyTokenizer_FindEncoding to handle
+ error conditions.
+
- Issue 3594: Fix Parser/tokenizer.c:fp_setreadl() to open the file being
tokenized by either a file path or file pointer for the benefit of
PyTokenizer_FindEncoding().
fclose(fp);
if (tok->encoding) {
encoding = (char *)PyMem_MALLOC(strlen(tok->encoding) + 1);
- strcpy(encoding, tok->encoding);
+ if (encoding)
+ strcpy(encoding, tok->encoding);
+ else
+ PyErr_NoMemory();
}
PyTokenizer_Free(tok);
return encoding;
memory. */
found_encoding = PyTokenizer_FindEncoding(fd);
lseek(fd, 0, 0); /* Reset position */
+ if (found_encoding == NULL && PyErr_Occurred())
+ return NULL;
encoding = (found_encoding != NULL) ? found_encoding :
(char*)PyUnicode_GetDefaultEncoding();
}