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

Unified Diff: core/src/fxcodec/fx_libopenjpeg/libopenjpeg20/pi.c

Issue 1245853002: Merge to M44: Fix an integer overflow issue in openJpeg (Closed) Base URL: https://pdfium.googlesource.com/pdfium@2403
Patch Set: Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: core/src/fxcodec/fx_libopenjpeg/libopenjpeg20/pi.c
diff --git a/core/src/fxcodec/fx_libopenjpeg/libopenjpeg20/pi.c b/core/src/fxcodec/fx_libopenjpeg/libopenjpeg20/pi.c
index 393a1e5540715d6d9b12a1148d66189935ea3cd0..d2ba3a14c6b2ec8f7748004a4a304630579408eb 100644
--- a/core/src/fxcodec/fx_libopenjpeg/libopenjpeg20/pi.c
+++ b/core/src/fxcodec/fx_libopenjpeg/libopenjpeg20/pi.c
@@ -36,6 +36,7 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
+#include <limits.h>
#include "opj_includes.h"
/** @defgroup PI PI - Implementation of a packet iterator */
@@ -1236,7 +1237,13 @@ opj_pi_iterator_t *opj_pi_create_decode(opj_image_t *p_image,
l_current_pi = l_pi;
/* memory allocation for include */
- l_current_pi->include = (OPJ_INT16*) opj_calloc((l_tcp->numlayers +1) * l_step_l, sizeof(OPJ_INT16));
+ l_current_pi->include = 00;
+ if
+ (l_step_l && l_tcp->numlayers < UINT_MAX / l_step_l - 1)
+ {
+ l_current_pi->include = (OPJ_INT16*) opj_calloc((l_tcp->numlayers + 1) * l_step_l, sizeof(OPJ_INT16));
+ }
+
if
(!l_current_pi->include)
{
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698