Thanks to visit codestin.com
Credit goes to github.com

Skip to content

FIX: segfault on truncated png #9257

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Nov 13, 2017
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
STY: tab -> space conversion in c code
  • Loading branch information
tacaswell committed Oct 1, 2017
commit 89bea54c79e9c444c184fc063d55b57d5e1e10e2
40 changes: 20 additions & 20 deletions src/_png.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -194,18 +194,18 @@ static PyObject *Py_write_png(PyObject *self, PyObject *args, PyObject *kwds)

switch (channels) {
case 1:
png_color_type = PNG_COLOR_TYPE_GRAY;
break;
png_color_type = PNG_COLOR_TYPE_GRAY;
break;
case 3:
png_color_type = PNG_COLOR_TYPE_RGB;
break;
png_color_type = PNG_COLOR_TYPE_RGB;
break;
case 4:
png_color_type = PNG_COLOR_TYPE_RGB_ALPHA;
break;
png_color_type = PNG_COLOR_TYPE_RGB_ALPHA;
break;
default:
PyErr_SetString(PyExc_ValueError,
"Buffer must be an NxMxD array with D in 1, 3, 4 "
"(grayscale, RGB, RGBA)");
"Buffer must be an NxMxD array with D in 1, 3, 4 "
"(grayscale, RGB, RGBA)");
goto exit;
}

Expand Down Expand Up @@ -349,20 +349,20 @@ static PyObject *Py_write_png(PyObject *self, PyObject *args, PyObject *kwds)
sig_bit.alpha = 0;
switch (png_color_type) {
case PNG_COLOR_TYPE_GRAY:
sig_bit.gray = 8;
sig_bit.red = 0;
sig_bit.green = 0;
sig_bit.blue = 0;
break;
sig_bit.gray = 8;
sig_bit.red = 0;
sig_bit.green = 0;
sig_bit.blue = 0;
break;
case PNG_COLOR_TYPE_RGB_ALPHA:
sig_bit.alpha = 8;
// fall through
sig_bit.alpha = 8;
// fall through
case PNG_COLOR_TYPE_RGB:
sig_bit.gray = 0;
sig_bit.red = 8;
sig_bit.green = 8;
sig_bit.blue = 8;
break;
sig_bit.gray = 0;
sig_bit.red = 8;
sig_bit.green = 8;
sig_bit.blue = 8;
break;
default:
PyErr_SetString(PyExc_RuntimeError, "internal error, bad png_color_type");
goto exit;
Expand Down