Skip to content

Commit

Permalink
fixed imageCreateFromLazyByteString, peek from CString with specified…
Browse files Browse the repository at this point in the history
… length,

to avoid recognizing zeroes in data as NULL-termination in string
  • Loading branch information
Dmitriy Nikitinskiy committed Jan 23, 2013
1 parent 1d6cff7 commit 439c8d2
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 2 additions & 0 deletions wxc/src/cpp/eljimage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ EWXWEXPORT(size_t,wxImage_ConvertToByteString)(wxImage* self,int type,char* data
wxMemoryOutputStream out;
self->SaveFile(out, type);
size_t len = out.GetLength();
if( !data ) return len;
return out.CopyTo(data, len);
}

Expand All @@ -38,6 +39,7 @@ EWXWEXPORT(size_t,wxImage_ConvertToLazyByteString)(wxImage* self,int type,char*
wxMemoryOutputStream out;
self->SaveFile(out, type);
size_t len = out.GetLength();
if( !data ) return len;
return out.CopyTo(data, len);
}

Expand Down
4 changes: 2 additions & 2 deletions wxcore/src/haskell/Graphics/UI/WXCore/WxcTypes.hs
Original file line number Diff line number Diff line change
Expand Up @@ -723,7 +723,7 @@ withStringResult f
then return ""
else withCString (replicate (fromCInt len) ' ') $ \cstr ->
do f cstr
peekCString cstr
peekCStringLen (cstr,fromCInt len)

withWStringResult :: (Ptr CWchar -> IO CInt) -> IO String
withWStringResult f
Expand All @@ -746,7 +746,7 @@ withByteStringResult f
then return $ BC.pack ""
else withCString (replicate (fromCInt len) ' ') $ \cstr ->
do f cstr
B.packCString cstr
B.packCStringLen (cstr,fromCInt len)

withLazyByteStringResult :: (Ptr CChar -> IO CInt) -> IO LB.ByteString
withLazyByteStringResult f
Expand Down

0 comments on commit 439c8d2

Please sign in to comment.