Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 982617e

Browse files
committed
Fixed possible buffer overrun.
svn path=/trunk/matplotlib/; revision=4834
1 parent 6229098 commit 982617e

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

src/agg_py_path_iterator.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ class PathIterator
4343
Py_XDECREF(m_codes);
4444
}
4545

46-
static const char code_map[];
46+
static const unsigned code_map[];
4747

4848
private:
4949
inline unsigned vertex(unsigned idx, double* x, double* y)
@@ -66,7 +66,8 @@ class PathIterator
6666
{
6767
if (m_iterator >= m_total_vertices) return agg::path_cmd_stop;
6868
unsigned code = vertex(m_iterator++, x, y);
69-
while (MPL_isnan64(*x) || MPL_isnan64(*y)) {
69+
while ((MPL_isnan64(*x) || MPL_isnan64(*y)) &&
70+
m_iterator < m_total_vertices) {
7071
vertex(m_iterator++, x, y);
7172
code = agg::path_cmd_move_to;
7273
}
@@ -90,7 +91,7 @@ class PathIterator
9091
};
9192

9293
// Maps path codes on the Python side to agg path commands
93-
const char PathIterator::code_map[] =
94+
const unsigned PathIterator::code_map[] =
9495
{0,
9596
agg::path_cmd_move_to,
9697
agg::path_cmd_line_to,

0 commit comments

Comments
 (0)