Permalink
Browse files

Don't swallow potential bugs with Data marking and freeing.

  • Loading branch information...
brixen committed Jan 8, 2013
1 parent e5c2724 commit 2cf6d5943247a7a01dcc9c51e13e126466a3430a
Showing with 10 additions and 4 deletions.
  1. +10 −4 vm/builtin/data.cpp
View
@@ -69,10 +69,13 @@ namespace rubinius {
}
void Data::finalize(STATE, Data* data) {
- // MRI only calls free if the data_ptr is not NULL.
- void* data_ptr;
+ if(data->freed_p()) {
+ std::cerr << "Data::finalize called for already freed object" << std::endl;
+ return;
+ }
- if(!data->freed_p() && (data_ptr = data->data(state))) {
+ // MRI only calls free if the data_ptr is not NULL.
+ if(void* data_ptr = data->data(state)) {
Data::FreeFunctor f = data->free(state);
if(f) {
// If the user specifies -1, then we call free. We check here rather
@@ -93,7 +96,10 @@ namespace rubinius {
Data* data = force_as<Data>(t);
- if(data->freed_p()) return;
+ if(data->freed_p()) {
+ std::cerr << "Data::Info::mark called for already freed object" << std::endl;
+ return;
+ }
RDataShadow* rdata = data->rdata();

0 comments on commit 2cf6d59

Please sign in to comment.