aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorJohannes Schickel2010-01-12 20:19:45 +0000
committerJohannes Schickel2010-01-12 20:19:45 +0000
commit3578f8d091f55960868a4a36e4b48bf3a03d3659 (patch)
tree04e86e7a305230c6370941da8f4e9eb4b91cb3a9 /engines
parent36444740b3e02318c8334475cdf5d5967c733719 (diff)
downloadscummvm-rg350-3578f8d091f55960868a4a36e4b48bf3a03d3659.tar.gz
scummvm-rg350-3578f8d091f55960868a4a36e4b48bf3a03d3659.tar.bz2
scummvm-rg350-3578f8d091f55960868a4a36e4b48bf3a03d3659.zip
Fix some memory leaks caused by never freeing the allocated memory, which is pointed at by KernelFuncWithSignature::signature.
svn-id: r47275
Diffstat (limited to 'engines')
-rw-r--r--engines/sci/engine/kernel.cpp12
-rw-r--r--engines/sci/engine/kernel.h3
2 files changed, 11 insertions, 4 deletions
diff --git a/engines/sci/engine/kernel.cpp b/engines/sci/engine/kernel.cpp
index e5512da4ce..4993e9245b 100644
--- a/engines/sci/engine/kernel.cpp
+++ b/engines/sci/engine/kernel.cpp
@@ -392,11 +392,17 @@ Kernel::Kernel(ResourceManager *resMan, Common::String gameId) : _resMan(resMan)
}
Kernel::~Kernel() {
+ for (KernelFuncsContainer::iterator i = _kernelFuncs.begin(); i != _kernelFuncs.end(); ++i)
+ // TODO: Doing a const_cast is not that nice actually... But since KernelFuncWithSignature
+ // keeps the signature member as "const char *" there is no way around it.
+ // Think of a clever way to avoid this.
+ free(const_cast<char *>(i->signature));
}
uint Kernel::getSelectorNamesSize() const {
return _selectorNames.size();
}
+
const Common::String &Kernel::getSelectorName(uint selector) const {
return _selectorNames[selector];
}
@@ -404,6 +410,7 @@ const Common::String &Kernel::getSelectorName(uint selector) const {
uint Kernel::getKernelNamesSize() const {
return _kernelNames.size();
}
+
const Common::String &Kernel::getKernelName(uint number) const {
// FIXME: The following check is a temporary workaround for
// an issue leading to crashes when using the debugger's backtrace
@@ -504,7 +511,7 @@ static void kernel_compile_signature(const char **s) {
if (!src)
return; // NULL signature: Nothing to do
- result = (char*)malloc(strlen(*s) + 1);
+ result = (char *)malloc(strlen(*s) + 1);
while (*src) {
char c;
@@ -554,11 +561,10 @@ static void kernel_compile_signature(const char **s) {
ellipsis = 1;
break;
- default: {
+ default:
error("INTERNAL ERROR when compiling kernel function signature '%s': (%02x) not understood (aka"
" '%c')\n", *s, c, c);
}
- }
} while (*src && (*src == KSIG_SPEC_ELLIPSIS || (c < 'a' && c != KSIG_SPEC_ANY)));
// To handle sum types
diff --git a/engines/sci/engine/kernel.h b/engines/sci/engine/kernel.h
index 9e24f2f2d1..abf090eab6 100644
--- a/engines/sci/engine/kernel.h
+++ b/engines/sci/engine/kernel.h
@@ -84,7 +84,8 @@ public:
void dumpScriptClass(char *data, int seeker, int objsize);
SelectorCache _selectorCache; /**< Shortcut list for important selectors */
- Common::Array<KernelFuncWithSignature> _kernelFuncs; /**< Table of kernel functions */
+ typedef Common::Array<KernelFuncWithSignature> KernelFuncsContainer;
+ KernelFuncsContainer _kernelFuncs; /**< Table of kernel functions */
private:
/**