Developer forums (C::B DEVELOPMENT STRICTLY!) > Plugins development

unknown exception

<< < (10/17) > >>

thomas:
There is no 0x00 in a bin64 encoded string :)  Luckily, or we couldn't do that :)

ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+   <---  these are all.



--- Quote from: grv575 on December 16, 2005, 09:23:08 pm ---However the base64 decode algorithm builds up a return string starting with ' ', followed by 0x0, etc.  This is not OK for a string value.  i.e. The returned string is 0x15,0x0, "wxDocking-Stream-v1.0"
--- End quote ---
Right, but the data really looks like this. This is correct. And wxString is meant to hold 0x00 values. This certainly works.

grv575:
See message one up.  I just upped the screenshot.  I'm not sure how that <bin></bin> string got calculated, but it looks incorrect in Unicode mode.  The first two boxes in the screenshot are 0x15,0x0.  These should all be spaces I would think.

grv575:
Well, even if 0x0 nulls are OK in wxStrings, when we build a memory stream from the c_string version of the wxString, doesn't this chop off at the first 0x0?


--- Code: ---    buf = Manager::Get()->GetConfigManager(_T("app"))->ReadBinary(_T("/main_frame/layout"));
    wxMemoryInputStream ms(buf.c_str(), buf.Length());

--- End code ---

And then the ms memorystream wouldn't hold all it should, so it crashes a few lines below.

Edit:

When I put a watch on ms after those two lines, gdb gives <incomplete type>.  Tracing into the wxSlideBar::LoadFromStream -> wxUtil::ReadString() call,

wxDockit/src/generic/util.cpp:34

--- Code: ---    stream.Read( &size, sizeof( size ) );

--- End code ---

sets size to 1392520448.  We then allocate a buffer:

--- Code: ---    char* psz = new char[size + 1];
--- End code ---

whoops.

thomas:

--- Quote from: grv575 on December 16, 2005, 09:32:41 pm ---Well, even if 0x0 nulls are OK in wxStrings, when we build a memory stream from the c_string version of the wxString, doesn't this chop off at the first 0x0?
--- End quote ---
No. wxMemoryInputStream comes in two flavours.


--- Code: ---    wxMemoryInputStream ms(buf.c_str(), buf.Length());
                                        ^^^^^^^^^^^^

--- End code ---

This one is safe to be used with 0x0, the other is not.

grv575:
Look at the screenshot.  Specifically the size variable value after reading the stream.  Also at where the gdb -> arrow is.  I trace one more line, (allocate that huge char buffer) and it gives the exception.  See it's heap corruption after all.  Malloc() == :)

Something wrong with the stream encode or decode or... at least with a unicode build.


[attachment deleted by admin]

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version