diff options
| author | jan.nijtmans <nijtmans@users.sourceforge.net> | 2025-05-26 12:59:04 (GMT) |
|---|---|---|
| committer | jan.nijtmans <nijtmans@users.sourceforge.net> | 2025-05-26 12:59:04 (GMT) |
| commit | 05271f5f1347de19b568daa4ac49eccca923ca96 (patch) | |
| tree | 57b76e599dd2d588c440328588d069ecb33889f2 /generic/tclArithSeries.c | |
| parent | 31df7569748f126a4cc0e88854b1019531b5073e (diff) | |
| parent | c21ec96ab359f5f26f51e1103bb3671e240be592 (diff) | |
| download | tcl-core-attemptgetstring.zip tcl-core-attemptgetstring.tar.gz tcl-core-attemptgetstring.tar.bz2 | |
Add some more Tcl_Attempt* functionscore-attemptgetstring
Diffstat (limited to 'generic/tclArithSeries.c')
| -rwxr-xr-x | generic/tclArithSeries.c | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/generic/tclArithSeries.c b/generic/tclArithSeries.c index c075369..3f4b98b 100755 --- a/generic/tclArithSeries.c +++ b/generic/tclArithSeries.c @@ -1175,9 +1175,7 @@ UpdateStringOfArithSeries( Tcl_PrintDouble(NULL,d,tmp); elen = strlen(tmp); if (bytlen > TCL_SIZE_MAX - elen) { - /* overflow, todo: check we could use some representation instead of the panic - * to signal it is too large for string representation, because too heavy */ - Tcl_Panic("UpdateStringOfArithSeries: too large to represent"); + goto repTooLarge; } bytlen += elen; } @@ -1188,8 +1186,16 @@ UpdateStringOfArithSeries( * Pass 2: generate the string repr. */ - p = srep = Tcl_InitStringRep(arithSeriesObjPtr, NULL, bytlen); - TclOOM(p, bytlen+1); + p = srep = TclAttemptInitStringRep(arithSeriesObjPtr, NULL, bytlen); + if (!p) { + repTooLarge: + if (arithSeriesObjPtr->bytes) { + Tcl_Free(arithSeriesObjPtr->bytes); + arithSeriesObjPtr->bytes = 0; + } + arithSeriesObjPtr->length = bytlen; + return; + } if (!arithSeriesRepPtr->isDouble) { for (i = 0; i < arithSeriesRepPtr->len; i++) { |
