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
Branches
Tags
No related merge requests found
...@@ -57,10 +57,14 @@ public: ...@@ -57,10 +57,14 @@ public:
/// Give buffer to stream /// Give buffer to stream
void giveBuffer(VALUE str){ void giveBuffer(VALUE str){
FXuchar* copy = NULL;
Check_Type(str,T_STRING); Check_Type(str,T_STRING);
FXuchar* buffer=reinterpret_cast<FXuchar*>(StringValuePtr(str)); FXuchar* buffer=reinterpret_cast<FXuchar*>(StringValuePtr(str));
FXuval sp=RSTRING_LEN(str); FXuval sp=RSTRING_LEN(str);
self->giveBuffer(buffer,sp); if( FXMALLOC(&copy, FXuchar *, sp)) {
memcpy(copy, buffer, sp);
self->giveBuffer(copy,sp);
}
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment