From 7e92be6cd731888a4750bff54a0e03790afb3ab5 Mon Sep 17 00:00:00 2001 From: Pixel Date: Mon, 21 Jun 2010 13:57:14 -0700 Subject: Fixing stack abuses from HandleLua code... --- lib/LuaHandle.cc | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/lib/LuaHandle.cc b/lib/LuaHandle.cc index 789876e..e23d059 100644 --- a/lib/LuaHandle.cc +++ b/lib/LuaHandle.cc @@ -1280,7 +1280,6 @@ bool HandleLua::CanRead() const { L->call(1, 1); r = L->toboolean(); L->pop(); - L->pop(); return r; } @@ -1301,7 +1300,6 @@ bool HandleLua::CanWrite() const { L->call(1, 1); r = L->toboolean(); L->pop(); - L->pop(); return r; } @@ -1322,7 +1320,6 @@ bool HandleLua::CanSeek() const { L->call(1, 1); r = L->toboolean(); L->pop(); - L->pop(); return r; } @@ -1343,7 +1340,6 @@ bool HandleLua::CanWatch() const { L->call(1, 1); r = L->toboolean(); L->pop(); - L->pop(); return r; } @@ -1364,7 +1360,6 @@ String HandleLua::GetName() const { L->call(1, 1); r = L->tostring(); L->pop(); - L->pop(); return r; } @@ -1385,7 +1380,6 @@ off_t HandleLua::tell() const { L->call(1, 1); r = L->tonumber(); L->pop(); - L->pop(); return r; } @@ -1406,7 +1400,6 @@ ssize_t HandleLua::GetSize() const { L->call(1, 1); r = L->tonumber(); L->pop(); - L->pop(); return r; } @@ -1427,7 +1420,6 @@ time_t HandleLua::GetModif() const { L->call(1, 1); r = L->tonumber(); L->pop(); - L->pop(); return r; } @@ -1437,13 +1429,13 @@ void HandleLua::Flush() { L->gettable(); if (L->isnil()) { + L->pop(); L->pop(); return; } L->insert(-2); L->call(1, 0); - L->pop(); } off_t HandleLua::seek(off_t offset, int wheel) throw (GeneralException) { @@ -1454,6 +1446,7 @@ off_t HandleLua::seek(off_t offset, int wheel) throw (GeneralException) { L->gettable(); if (L->isnil()) { + L->pop(); L->pop(); throw GeneralException("This HandleLua doesn't have any seek method (or can't seek maybe)."); } @@ -1465,7 +1458,6 @@ off_t HandleLua::seek(off_t offset, int wheel) throw (GeneralException) { r = L->tonumber(); L->pop(); - L->pop(); return r; } @@ -1477,6 +1469,7 @@ ssize_t HandleLua::read(void * buf, size_t count) throw (GeneralException) { L->gettable(); if (L->isnil()) { + L->pop(); L->pop(); throw GeneralException("This HandleLua doesn't have any read method (or can't read maybe)."); } @@ -1499,7 +1492,6 @@ ssize_t HandleLua::read(void * buf, size_t count) throw (GeneralException) { } } - L->pop(); L->pop(); L->pop(); @@ -1514,6 +1506,7 @@ ssize_t HandleLua::write(const void * buf, size_t count) throw (GeneralException L->gettable(); if (L->isnil()) { + L->pop(); L->pop(); throw GeneralException("This HandleLua doesn't have any write method (or can't write maybe)."); } @@ -1525,7 +1518,6 @@ ssize_t HandleLua::write(const void * buf, size_t count) throw (GeneralException r = L->tonumber(); - L->pop(); L->pop(); return r; -- cgit v1.2.3