Skip to content

Commit 8caeeae

Browse files
committed
Throw exception when there are too many data points.
svn path=/trunk/matplotlib/; revision=6171
1 parent 24d662e commit 8caeeae

File tree

2 files changed

+45
-30
lines changed

2 files changed

+45
-30
lines changed

agg24/include/agg_rasterizer_cells_aa.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
#ifndef AGG_RASTERIZER_CELLS_AA_INCLUDED
3030
#define AGG_RASTERIZER_CELLS_AA_INCLUDED
3131

32+
#include <exception>
3233
#include <string.h>
3334
#include <math.h>
3435
#include "agg_math.h"
@@ -183,7 +184,9 @@ namespace agg
183184
{
184185
if((m_num_cells & cell_block_mask) == 0)
185186
{
186-
if(m_num_blocks >= cell_block_limit) return;
187+
if(m_num_blocks >= cell_block_limit) {
188+
throw "Agg rendering complexity exceeded.";
189+
}
187190
allocate_block();
188191
}
189192
*m_curr_cell_ptr++ = m_curr_cell;

src/_backend_agg.cpp

Lines changed: 41 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -941,7 +941,11 @@ RendererAgg::draw_path(const Py::Tuple& args) {
941941
if (snap)
942942
gc.isaa = false;
943943

944-
_draw_path(curve, has_clippath, face, gc);
944+
try {
945+
_draw_path(curve, has_clippath, face, gc);
946+
} catch (const char* e) {
947+
throw Py::RuntimeError(e);
948+
}
945949

946950
return Py::Object();
947951
}
@@ -1175,20 +1179,24 @@ RendererAgg::draw_path_collection(const Py::Tuple& args) {
11751179

11761180
PathListGenerator path_generator(paths);
11771181

1178-
_draw_path_collection_generic<PathListGenerator, 1, 1>
1179-
(master_transform,
1180-
cliprect,
1181-
clippath,
1182-
clippath_trans,
1183-
path_generator,
1184-
transforms_obj,
1185-
offsets_obj,
1186-
offset_trans,
1187-
facecolors_obj,
1188-
edgecolors_obj,
1189-
linewidths,
1190-
linestyles_obj,
1191-
antialiaseds);
1182+
try {
1183+
_draw_path_collection_generic<PathListGenerator, 1, 1>
1184+
(master_transform,
1185+
cliprect,
1186+
clippath,
1187+
clippath_trans,
1188+
path_generator,
1189+
transforms_obj,
1190+
offsets_obj,
1191+
offset_trans,
1192+
facecolors_obj,
1193+
edgecolors_obj,
1194+
linewidths,
1195+
linestyles_obj,
1196+
antialiaseds);
1197+
} catch (const char *e) {
1198+
throw Py::RuntimeError(e);
1199+
}
11921200

11931201
return Py::Object();
11941202
}
@@ -1310,20 +1318,24 @@ RendererAgg::draw_quad_mesh(const Py::Tuple& args) {
13101318
}
13111319

13121320
try {
1313-
_draw_path_collection_generic<QuadMeshGenerator, 0, 0>
1314-
(master_transform,
1315-
cliprect,
1316-
clippath,
1317-
clippath_trans,
1318-
path_generator,
1319-
transforms_obj,
1320-
offsets_obj,
1321-
offset_trans,
1322-
facecolors_obj,
1323-
edgecolors_obj,
1324-
linewidths,
1325-
linestyles_obj,
1326-
antialiaseds);
1321+
try {
1322+
_draw_path_collection_generic<QuadMeshGenerator, 0, 0>
1323+
(master_transform,
1324+
cliprect,
1325+
clippath,
1326+
clippath_trans,
1327+
path_generator,
1328+
transforms_obj,
1329+
offsets_obj,
1330+
offset_trans,
1331+
facecolors_obj,
1332+
edgecolors_obj,
1333+
linewidths,
1334+
linestyles_obj,
1335+
antialiaseds);
1336+
} catch (const char* e) {
1337+
throw Py::RuntimeError(e);
1338+
}
13271339
} catch (...) {
13281340
if (free_edgecolors) Py_XDECREF(edgecolors_obj.ptr());
13291341
throw;

0 commit comments

Comments
 (0)