Chromium Code Reviews| Index: ui/gfx/codec/png_codec.cc |
| diff --git a/ui/gfx/codec/png_codec.cc b/ui/gfx/codec/png_codec.cc |
| index ac386ad91d0b656e146776c8077694c881719e99..0fec249432d8d89fb953734033c601759458c1b7 100644 |
| --- a/ui/gfx/codec/png_codec.cc |
| +++ b/ui/gfx/codec/png_codec.cc |
| @@ -712,8 +712,11 @@ bool EncodeWithCompressionLevel(const unsigned char* input, |
| NULL, NULL, NULL); |
| if (!png_ptr) |
| return false; |
| + // info_ptr should have wider lifetime scope than destroyer that access it, |
| + // to avoid use-after-scope bugs. |
| + png_info* info_ptr; |
| PngWriteStructDestroyer destroyer(&png_ptr); |
|
dcheng
2016/12/14 22:32:47
Can we move this line down to after return false?
krasin1
2016/12/14 23:45:04
Daniel, Nico,
I have made a simplification that c
|
| - png_info* info_ptr = png_create_info_struct(png_ptr); |
| + info_ptr = png_create_info_struct(png_ptr); |
| if (!info_ptr) |
| return false; |
| destroyer.SetInfoStruct(&info_ptr); |