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

Skip to content

Commit 60ebac9

Browse files
committed
Be a little more pedantic about sscanf usage and check the return value.
svn path=/trunk/matplotlib/; revision=5210
1 parent 4535e6c commit 60ebac9

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

src/_tkagg.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,10 @@ PyAggImagePhoto(ClientData clientdata, Tcl_Interp* interp,
7676
return TCL_ERROR;
7777
}
7878
/* get array (or object that can be converted to array) pointer */
79-
sscanf (argv[2],"%lu",&aggl);
79+
if (sscanf (argv[2],"%lu",&aggl) != 1) {
80+
Tcl_AppendResult(interp, "error casting pointer", (char *) NULL);
81+
return TCL_ERROR;
82+
}
8083
aggo = (PyObject*)aggl;
8184
//aggo = (PyObject*)atol(argv[2]);
8285

@@ -97,7 +100,10 @@ PyAggImagePhoto(ClientData clientdata, Tcl_Interp* interp,
97100
}
98101

99102
/* check for bbox/blitting */
100-
sscanf (argv[4],"%lu",&bboxl);
103+
if (sscanf (argv[4],"%lu",&bboxl) != 1) {
104+
Tcl_AppendResult(interp, "error casting pointer", (char *) NULL);
105+
return TCL_ERROR;
106+
}
101107
bboxo = (PyObject*)bboxl;
102108

103109
//bboxo = (PyObject*)atol(argv[4]);

0 commit comments

Comments
 (0)