Skip to content
Snippets Groups Projects
Commit 4965951a authored by Lars Kanis's avatar Lars Kanis
Browse files

fix double free in FXMemoryStream#giveBuffer

The Ruby String buffer was free'd by GC and FXMemoryStream#close
parent a3fcce8f
No related branches found
No related tags found
No related merge requests found
......@@ -44,7 +44,7 @@ public:
return self->open(save_or_load,data);
}
}
// Take buffer away from stream
VALUE takeBuffer() {
FXuchar* buffer;
......@@ -54,19 +54,23 @@ public:
FXFREE(&buffer);
return result;
}
/// Give buffer to stream
void giveBuffer(VALUE str){
FXuchar* copy = NULL;
Check_Type(str,T_STRING);
FXuchar* buffer=reinterpret_cast<FXuchar*>(StringValuePtr(str));
FXuval sp=RSTRING_LEN(str);
self->giveBuffer(buffer,sp);
if( FXMALLOC(&copy, FXuchar *, sp)) {
memcpy(copy, buffer, sp);
self->giveBuffer(copy,sp);
}
}
}
/// Get position
FXlong position() const;
/// Destructor
virtual ~FXMemoryStream();
};
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment