Update brotlimodule.cc

This commit is contained in:
eustas 2016-01-25 12:07:39 +01:00
parent ca0ae4cbc0
commit c49918e1ee

View File

@ -29,10 +29,15 @@ static int mode_convertor(PyObject *o, BrotliParams::Mode *mode) {
return 0;
}
if (!as_uint8(o, mode) ||
(*mode != BrotliParams::MODE_GENERIC &&
*mode != BrotliParams::MODE_TEXT &&
*mode != BrotliParams::MODE_FONT)) {
int mode_value = -1;
if (!as_uint8(o, mode_value)) {
PyErr_SetString(BrotliError, "Invalid mode");
return 0;
}
*mode = (BrotliParams) mode_value;
if (*mode != BrotliParams::MODE_GENERIC &&
*mode != BrotliParams::MODE_TEXT &&
*mode != BrotliParams::MODE_FONT) {
PyErr_SetString(BrotliError, "Invalid mode");
return 0;
}