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

Skip to content

Commit e6e5cdf

Browse files
authored
Fix unhandled C++ exception
The C++ new operator will throw an C++ exception when the memory allocation fails.
1 parent e73dfe1 commit e6e5cdf

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 (...) {
120122
TCL_APPEND_RESULT(interp, "could not allocate memory", (char *)NULL);
121123
return TCL_ERROR;
122124
}

0 commit comments

Comments
 (0)