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

Skip to content

Commit 46b8d34

Browse files
NelleVMeeseeksDev[bot]
authored and
MeeseeksDev[bot]
committed
Backport PR #13289: Fix unhandled C++ exception
1 parent 6f0b80c commit 46b8d34

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
@@ -111,8 +111,10 @@ static int PyAggImagePhoto(ClientData clientdata, Tcl_Interp *interp, int
111111
destheight = (int)(y2 - y1);
112112
deststride = 4 * destwidth;
113113

114-
destbuffer = new agg::int8u[deststride * destheight];
115-
if (destbuffer == NULL) {
114+
try {
115+
destbuffer = new agg::int8u[deststride * destheight];
116+
}
117+
catch (std::bad_alloc) {
116118
TCL_APPEND_RESULT(interp, "could not allocate memory", (char *)NULL);
117119
return TCL_ERROR;
118120
}

0 commit comments

Comments
 (0)