From fada61905269aa299f85ae2a25a2786b6cbe4053 Mon Sep 17 00:00:00 2001 From: pooryorick Date: Tue, 24 Oct 2017 08:38:17 +0000 Subject: [fc1409fc91]: TclOO method with non-literal value for body argument causes segmentation fault --- generic/tclOOMethod.c | 1 + 1 file changed, 1 insertion(+) diff --git a/generic/tclOOMethod.c b/generic/tclOOMethod.c index 9c49caa..e8fad82 100644 --- a/generic/tclOOMethod.c +++ b/generic/tclOOMethod.c @@ -1314,6 +1314,7 @@ CloneProcedureMethod( */ bodyObj = Tcl_DuplicateObj(pmPtr->procPtr->bodyPtr); + Tcl_GetString(bodyObj); TclFreeIntRep(bodyObj); /* -- cgit v0.12 From 8e537759cf8215fe82bd51ca374f580d8b2c4a99 Mon Sep 17 00:00:00 2001 From: dkf Date: Tue, 24 Oct 2017 11:23:54 +0000 Subject: Added test case. --- tests/oo.test | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/tests/oo.test b/tests/oo.test index b538b60..2a6eb80 100644 --- a/tests/oo.test +++ b/tests/oo.test @@ -2048,6 +2048,17 @@ test oo-15.14 {OO: object cloning with target NS} -setup { } -cleanup { Cls destroy } -result {{} ::dupens::test-15.14} +test oo-15.15 {method cloning must ensure that there is a string representation of bodies} -setup { + oo::class create cls +} -body { + cls create foo + oo::objdefine foo { + method m1 {} [string map {a b} {return hello}] + } + [oo::copy foo] m1 +} -cleanup { + cls destroy +} -result hello test oo-16.1 {OO: object introspection} -body { info object -- cgit v0.12