BuildConnVal can create a dangling pointer

Looks like BuildConnVal() can be called from the connection destructor
and will set the origin to "this" and thus create a dangling pointer.
The connection will destruct but since conn_val has a reference
counting mechanism, it will still keep referring to the connection.

I propose to fix this by creating a destructing flag bit-field inside
connection. It will be initialized to zero, but set to 1 just when the
destructor is entered.

Looking forward to your comments! I will provide a patch, if desired.


Not sure I see that. Connection's dtor unrefs conn_val so this would
need to happen after the Unref(). The only line of code after the
Unref(conn_val) which could cause further connection events to be
raised is "delete root_analyzer" (although I think it shouldn't). If
that is indeed the case, I think the better fix is to move
Unref(conn_val) to the very end of the dtor.