[RCBC-60] struct freed before rasied Created: 18/Jul/12  Updated: 13/Nov/12  Resolved: 27/Jul/12

Status: Closed
Project: Couchbase Ruby client library
Component/s: library
Affects Version/s: 1.1.2
Fix Version/s: 1.1.3
Security Level: Public

Type: Bug Priority: Major
Reporter: James Mauss Assignee: Sergey Avseyev
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

the ctx struct's freed before the exception ( exc ) is raised - so it references invalid memory

ext/couchbase_ext/couchbase_ext.c- exc = ctx->exception; <----
ext/couchbase_ext/couchbase_ext.c- extended = ctx->extended;
ext/couchbase_ext/couchbase_ext.c: free(ctx); <------
ext/couchbase_ext/couchbase_ext.c- if (exc != Qnil) {
ext/couchbase_ext/couchbase_ext.c- rb_exc_raise(exc); <------
ext/couchbase_ext/couchbase_ext.c- }

Comment by Sergey Avseyev [ 18/Jul/12 ]
free(ctx) means deallocate the memory of the struct. ctx->exception is just a pointer, and it is valid
Comment by Sergey Avseyev [ 18/Jul/12 ]
It would be better if I'll get stacktrace or minimal working script (or both)
Generated at Tue Sep 16 18:05:28 CDT 2014 using JIRA 5.2.4#845-sha1:c9f4cc41abe72fb236945343a1f485c2c844dac9.