Fix a missing refcount in the Go host error trapping.

Err_trap returns an `incremented` Err object, so we need to return an
incremented reference rather than return the pointer extracted from the
Err Go wrapper directly.  If we don't do that, we're arming a time bomb
which will go off the first GC after the caller disposes of their
refcount.


Project: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/commit/fde1b7db
Tree: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/tree/fde1b7db
Diff: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/diff/fde1b7db

Branch: refs/heads/master
Commit: fde1b7dbd5cf460342eb82f94fde071d2f032149
Parents: 2a77280
Author: Marvin Humphrey <[email protected]>
Authored: Wed Dec 23 16:31:37 2015 -0800
Committer: Marvin Humphrey <[email protected]>
Committed: Mon Dec 28 11:23:50 2015 -0800

----------------------------------------------------------------------
 runtime/go/clownfish/clownfish.go | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/fde1b7db/runtime/go/clownfish/clownfish.go
----------------------------------------------------------------------
diff --git a/runtime/go/clownfish/clownfish.go 
b/runtime/go/clownfish/clownfish.go
index 1986109..340b0b0 100644
--- a/runtime/go/clownfish/clownfish.go
+++ b/runtime/go/clownfish/clownfish.go
@@ -619,7 +619,7 @@ func GoCfish_TrapErr_internal(routine C.CFISH_Err_Attempt_t,
        err := TrapErr(func() { C.GoCfish_RunRoutine(routine, context) })
        if err != nil {
                ptr := (err.(Err)).TOPTR()
-               return ((*C.cfish_Err)(unsafe.Pointer(ptr)))
+               return 
((*C.cfish_Err)(unsafe.Pointer(C.cfish_incref(unsafe.Pointer(ptr)))))
        }
        return nil
 }

Reply via email to