summaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
authorEven Rouault <even.rouault@spatialys.com>2020-05-19 22:26:22 +0200
committerEven Rouault <even.rouault@spatialys.com>2020-05-20 20:31:28 +0200
commit4ab2ed090747ad2f22e78d45a1db5640d40e6a34 (patch)
tree84a5ac523007bd2f01fb112ceb1a22d8e3fb8d3b /src/lib
parentc6a413a42394836b956846cc037dd8297b732f44 (diff)
opj_j2k_setup_encoder(): add validation of tile width and height to avoid potential division by zero
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/openjp2/j2k.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/lib/openjp2/j2k.c b/src/lib/openjp2/j2k.c
index 842c8caa..1a6cdc3e 100644
--- a/src/lib/openjp2/j2k.c
+++ b/src/lib/openjp2/j2k.c
@@ -7823,6 +7823,14 @@ OPJ_BOOL opj_j2k_setup_encoder(opj_j2k_t *p_j2k,
*/
if (parameters->tile_size_on) {
+ if (cp->tdx == 0) {
+ opj_event_msg(p_manager, EVT_ERROR, "Invalid tile width\n");
+ return OPJ_FALSE;
+ }
+ if (cp->tdy == 0) {
+ opj_event_msg(p_manager, EVT_ERROR, "Invalid tile height\n");
+ return OPJ_FALSE;
+ }
cp->tw = (OPJ_UINT32)opj_int_ceildiv((OPJ_INT32)(image->x1 - cp->tx0),
(OPJ_INT32)cp->tdx);
cp->th = (OPJ_UINT32)opj_int_ceildiv((OPJ_INT32)(image->y1 - cp->ty0),