diff options
author | MikalaiR <nikolay.romanovich@narod.ru> | 2016-01-31 10:20:43 +0000 |
---|---|---|
committer | MikalaiR <nikolay.romanovich@narod.ru> | 2016-01-31 10:20:43 +0000 |
commit | 62767bfaf7f7fb988b826da797463545db14b3b5 (patch) | |
tree | d72ceb32a424a4cc6976c8f1c0ee4566c368ab9b | |
parent | 31d9726d61bd002b4405781383b6a58433dd9296 (diff) |
MirLua: fix memory corruptions
git-svn-id: http://svn.miranda-ng.org/main/trunk@16201 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
-rw-r--r-- | plugins/MirLua/src/m_database.cpp | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/plugins/MirLua/src/m_database.cpp b/plugins/MirLua/src/m_database.cpp index de1d0e1006..a8cb78f435 100644 --- a/plugins/MirLua/src/m_database.cpp +++ b/plugins/MirLua/src/m_database.cpp @@ -183,7 +183,7 @@ static int array__call(lua_State *L) BLOB *blob = (BLOB*)lua_newuserdata(L, sizeof(BLOB));
blob->cbSize = size;
blob->pBlobData = (BYTE*)mir_alloc(sizeof(BYTE) * blob->cbSize);
- memcpy(blob->pBlobData, udata, sizeof(BYTE));
+ memcpy(blob->pBlobData, udata, sizeof(BYTE)* blob->cbSize);
luaL_setmetatable(L, MT_BLOB);
return 1;
@@ -194,7 +194,7 @@ static int array__index(lua_State *L) BLOB *blob = (BLOB*)luaL_checkudata(L, 1, MT_BLOB);
int idx = luaL_checkinteger(L, 2);
- lua_pushinteger(L, (char)&blob->pBlobData[idx - 1]);
+ lua_pushinteger(L, (uint8_t)blob->pBlobData[idx - 1]);
return 1;
}
@@ -203,7 +203,7 @@ static int array__newindex(lua_State *L) {
BLOB *blob = (BLOB*)luaL_checkudata(L, 1, MT_BLOB);
int idx = luaL_checkinteger(L, 2);
- char val = (char)luaL_checkinteger(L, 3);
+ uint8_t val = (uint8_t)luaL_checkinteger(L, 3);
blob->pBlobData[idx - 1] = val;
@@ -223,7 +223,7 @@ static int array__tostring(lua_State *L) {
BLOB *blob = (BLOB*)luaL_checkudata(L, 1, MT_BLOB);
- ptrA res((char*)mir_alloc(blob->cbSize * 2 + 1));
+ char *res = (char*)alloca(blob->cbSize * 2 + 1);
bin2hex(blob->pBlobData, blob->cbSize, res);
lua_pushstring(L, res);
@@ -292,7 +292,7 @@ static int lua_GetSetting(lua_State *L) BLOB *blob = (BLOB*)lua_newuserdata(L, sizeof(BLOB));
blob->cbSize = dbv.cpbVal;
blob->pBlobData = (BYTE*)mir_alloc(sizeof(BYTE) * blob->cbSize);
- memcpy(blob->pBlobData, dbv.pbVal, sizeof(BYTE));
+ memcpy(blob->pBlobData, dbv.pbVal, sizeof(BYTE) * blob->cbSize);
luaL_setmetatable(L, MT_BLOB);
}
break;
@@ -543,7 +543,7 @@ static int dbcw__index(lua_State *L) BLOB *blob = (BLOB*)lua_newuserdata(L, sizeof(BLOB));
blob->cbSize = dbcw->value.cpbVal;
blob->pBlobData = (BYTE*)mir_alloc(sizeof(BYTE) * blob->cbSize);
- memcpy(blob->pBlobData, dbcw->value.pbVal, sizeof(BYTE));
+ memcpy(blob->pBlobData, dbcw->value.pbVal, sizeof(BYTE) * blob->cbSize);
luaL_setmetatable(L, MT_BLOB);
}
break;
|