Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(175)

Issue 1231353003: Merge to M44: Cleanup if early return from opj_j2k_copy_default_tcp_and_create_tcd(). (Closed)

Created:
5 years, 5 months ago by Lei Zhang
Modified:
5 years, 5 months ago
Reviewers:
jun_fang
CC:
pdfium-reviews_googlegroups.com
Base URL:
https://pdfium.googlesource.com/pdfium@2403
Target Ref:
refs/heads/chromium/2403
Visibility:
Public.

Description

Merge to M44: Cleanup if early return from opj_j2k_copy_default_tcp_and_create_tcd(). The opj_j2k_copy_default_tcp_and_create_tcp() function memcpy's a top-level struct, and then replaces pointers to memory owned by the original struct with new blocks of memory. Unfortunately, an early return can leave the copy with pointers to memory it doesn't own, which causes problems when cleaning up the partially-initialized struct. The referenced bug is triggered when we get a return at original line 7969 or 7385 due to OOM. Moral of the story: creating a "copy constructor" equivalent based on memcpy() instead of copying field by field for structs containing pointers is usually a bad idea. BUG=486538 R=jun_fang@foxitsoftware.com Review URL: https://codereview.chromium.org/1138033007 (cherry picked from commit 3b60890f6ee807a8bfc44056443f77603c23e6b0) Committed: https://pdfium.googlesource.com/pdfium/+/0839207dc3fedd322d1d784e275d4d5f8cb8e970

Patch Set 1 #

Unified diffs Side-by-side diffs Delta from patch set Stats (+10 lines, -0 lines) Patch
M core/src/fxcodec/fx_libopenjpeg/libopenjpeg20/j2k.c View 3 chunks +10 lines, -0 lines 0 comments Download

Messages

Total messages: 2 (0 generated)
Lei Zhang
TBR
5 years, 5 months ago (2015-07-13 21:42:01 UTC) #1
Lei Zhang
5 years, 5 months ago (2015-07-13 21:42:11 UTC) #2
Message was sent while issue was closed.
Committed patchset #1 (id:1) manually as
0839207dc3fedd322d1d784e275d4d5f8cb8e970 (presubmit successful).

Powered by Google App Engine
This is Rietveld 408576698