diff options
| author | ferrieux@users.sourceforge.net <ferrieux> | 2012-12-22 19:05:34 (GMT) |
|---|---|---|
| committer | ferrieux@users.sourceforge.net <ferrieux> | 2012-12-22 19:05:34 (GMT) |
| commit | 90a906b49950acee138a2d93310fe5b16dd5d66c (patch) | |
| tree | a2f6ec0e2a2037ff55e2d98ba093a9fb64b5d77b /generic/tclUtil.c | |
| parent | c3a639702b19b9eb487723e3e28e58478f695272 (diff) | |
| download | tcl-90a906b49950acee138a2d93310fe5b16dd5d66c.zip tcl-90a906b49950acee138a2d93310fe5b16dd5d66c.tar.gz tcl-90a906b49950acee138a2d93310fe5b16dd5d66c.tar.bz2 | |
Stop leaking allocated space when objifying a zero-length DString. [Bug 3598150] spotted by afredd.
Diffstat (limited to 'generic/tclUtil.c')
| -rw-r--r-- | generic/tclUtil.c | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/generic/tclUtil.c b/generic/tclUtil.c index 13e54ec..ddf067b 100644 --- a/generic/tclUtil.c +++ b/generic/tclUtil.c @@ -2927,14 +2927,16 @@ TclDStringToObj( { Tcl_Obj *result; - if (dsPtr->length == 0) { - TclNewObj(result); - } else if (dsPtr->string == dsPtr->staticSpace) { - /* - * Static buffer, so must copy. - */ - - TclNewStringObj(result, dsPtr->string, dsPtr->length); + if (dsPtr->string == dsPtr->staticSpace) { + if (dsPtr->length == 0) { + TclNewObj(result); + } else { + /* + * Static buffer, so must copy. + */ + + TclNewStringObj(result, dsPtr->string, dsPtr->length); + } } else { /* * Dynamic buffer, so transfer ownership and reset. |
