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

Skip to content

Commit 9c1d70b

Browse files
authored
Merge pull request #13289 from cgohlke/patch-3
Fix unhandled C++ exception
2 parents ce33de7 + 41af6fc commit 9c1d70b

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/_tkagg.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,8 +115,10 @@ static int PyAggImagePhoto(ClientData clientdata, Tcl_Interp *interp, int
115115
destheight = (int)(y2 - y1);
116116
deststride = 4 * destwidth;
117117

118-
destbuffer = new agg::int8u[deststride * destheight];
119-
if (destbuffer == NULL) {
118+
try {
119+
destbuffer = new agg::int8u[deststride * destheight];
120+
}
121+
catch (std::bad_alloc) {
120122
TCL_APPEND_RESULT(interp, "could not allocate memory", (char *)NULL);
121123
return TCL_ERROR;
122124
}

0 commit comments

Comments
 (0)