Skip to content
Closed
Show file tree
Hide file tree
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
Next Next commit
Change hard coded limits of (32768, 32768) pixels for an image to a p…
…latform dependant size of (INT_MAX, INT_MAX)
  • Loading branch information
nicolas-pascal committed Sep 2, 2014
commit 75595dabcf8f65ec62295b7523493124be2f07fb
6 changes: 4 additions & 2 deletions src/_backend_agg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2518,9 +2518,11 @@ Py::Object _backend_agg_module::new_renderer(const Py::Tuple &args,
unsigned int height = (int)Py::Int(args[1]);
double dpi = Py::Float(args[2]);

if (width > 1 << 15 || height > 1 << 15)
char msg [256];
if (width > INT_MAX || height > INT_MAX)
{
throw Py::ValueError("width and height must each be below 32768");
sprintf(msg, "width and height must each be below %d", INT_MAX);
throw Py::ValueError(msg);
}

if (dpi <= 0.0)
Expand Down
1 change: 1 addition & 0 deletions src/_backend_agg.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#ifndef __BACKEND_AGG_H
#define __BACKEND_AGG_H
#include <utility>
#include <climits>
#include "CXX/Extensions.hxx"

#include "agg_arrowhead.h"
Expand Down
26 changes: 18 additions & 8 deletions src/_image.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -786,9 +786,11 @@ _image_module::from_images(const Py::Tuple& args)
size_t numrows = (long)Py::Int(args[0]);
size_t numcols = (long)Py::Int(args[1]);

if (numrows >= 32768 || numcols >= 32768)
char msg [256];
if (numrows >= INT_MAX || numcols >= INT_MAX)
{
throw Py::RuntimeError("numrows and numcols must both be less than 32768");
sprintf(msg, "numrows and numcols must both be less than %d", INT_MAX);
throw Py::ValueError(msg);
}

Py::SeqBase<Py::Object> tups = args[2];
Expand Down Expand Up @@ -1268,9 +1270,11 @@ _image_module::frombuffer(const Py::Tuple& args)
size_t x = (long)Py::Int(args[1]);
size_t y = (long)Py::Int(args[2]);

if (x >= 32768 || y >= 32768)
char msg [256];
if (x >= INT_MAX || y >= INT_MAX)
{
throw Py::ValueError("x and y must both be less than 32768");
sprintf(msg, "numrows and numcols must both be less than %d", INT_MAX);
throw Py::ValueError(msg);
}

int isoutput = Py::Int(args[3]);
Expand Down Expand Up @@ -1576,9 +1580,11 @@ _image_module::pcolor(const Py::Tuple& args)
Py::Tuple bounds = args[5];
unsigned int interpolation = (unsigned long)Py::Int(args[6]);

if (rows >= 32768 || cols >= 32768)
char msg [256];
if (rows >= INT_MAX || cols >= INT_MAX)
{
throw Py::ValueError("rows and cols must both be less than 32768");
sprintf(msg, "rows and cols must both be less than %d", INT_MAX);
throw Py::ValueError(msg);
}

if (bounds.length() != 4)
Expand Down Expand Up @@ -1822,11 +1828,15 @@ _image_module::pcolor2(const Py::Tuple& args)
Py::Tuple bounds = args[5];
Py::Object bgp = args[6];

if (rows >= 32768 || cols >= 32768)
char msg [256];
if (rows >= INT_MAX || cols >= INT_MAX)
{
throw Py::ValueError("rows and cols must both be less than 32768");
sprintf(msg, "rows and cols must both be less than %d", INT_MAX);
throw Py::ValueError(msg);
}



if (bounds.length() != 4)
{
throw Py::TypeError("Incorrect number of bounds (4 expected)");
Expand Down
1 change: 1 addition & 0 deletions src/_image.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#ifndef _IMAGE_H
#define _IMAGE_H
#include <utility>
#include <climits>
#include "Python.h"

#include "agg_trans_affine.h"
Expand Down