summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/Handle.h2
-rw-r--r--lib/Handle.cc4
-rw-r--r--lib/LuaHandle.cc7
3 files changed, 6 insertions, 7 deletions
diff --git a/include/Handle.h b/include/Handle.h
index 8b9f866..a22c8e0 100644
--- a/include/Handle.h
+++ b/include/Handle.h
@@ -73,7 +73,7 @@ class Handle : public Base {
static int zlib_deflate(Handle * in, Handle * out) throw (GeneralException);
#ifdef HAVE_UCL
static int ucl_compress(Handle * in, Handle * out, int len_in = -1) throw (GeneralException);
- static int ucl_decompress(Handle * in, Handle * out, int len_in = -1) throw (GeneralException);
+ static int ucl_decompress(Handle * in, Handle * out, unsigned int len_out, int len_in = -1) throw (GeneralException);
#endif
protected:
Handle(int h);
diff --git a/lib/Handle.cc b/lib/Handle.cc
index 1701cd9..65935a4 100644
--- a/lib/Handle.cc
+++ b/lib/Handle.cc
@@ -901,15 +901,13 @@ int Handle::ucl_compress(Handle * in, Handle * out, int len_in) throw (GeneralEx
return len_out;
}
-int Handle::ucl_decompress(Handle * in, Handle * out, int len_in) throw (GeneralException) {
+int Handle::ucl_decompress(Handle * in, Handle * out, unsigned int len_out, int len_in) throw (GeneralException) {
if (ucl_init() != UCL_E_OK)
throw GeneralException("ucl_init failed");
unsigned char * b_in, * b_out;
- unsigned int len_out;
if (len_in < 0) len_in = in->GetSize() - in->tell();
- len_out = len_in + len_in / 8 + 256;
b_in = (unsigned char *) malloc(len_in);
b_out = (unsigned char *) malloc(len_out);
diff --git a/lib/LuaHandle.cc b/lib/LuaHandle.cc
index 472f3d6..ec1f573 100644
--- a/lib/LuaHandle.cc
+++ b/lib/LuaHandle.cc
@@ -610,16 +610,17 @@ int sLuaHandle::ucl_decompress(lua_State * __L) {
Lua * L = Lua::find(__L);
int n = L->gettop();
Handle * s, * d;
- int r;
+ int r, l;
- if (n != 2) {
+ if ((n != 3) || (!L->isnumber(3))) {
L->error("Incorrect arguments to method `Handle::ucl_decompress'");
}
s = L->recast<Handle>(1);
d = L->recast<Handle>(2);
+ l = L->tonumber(3);
- r = Handle::ucl_decompress(s, d);
+ r = Handle::ucl_decompress(s, d, l);
L->push((lua_Number) r);