Menu

#1 memory leak in mathexpr.cpp

open
nobody
None
5
2006-11-30
2006-11-30
hm_
No

I've compiled GLplot under MS VisualC++ 7.0. In order to achieve this, I've downloaded the original version of third-party mathexpr library, and found a memory leak in mathexpr.cpp there:
s=new char[n];
// HACK: mlkz memory leak when op == Num || op == Var
switch(op){
case Num:return ValToStr(ValC);
case Var:return CopyStr(pvar->name);
............

This error can be found in your patched mathexpr.cpp as well. Here is the solution:

s=new char[n]; // HACK: mlkz memory leak when op == Num || op == Var
switch(op){
case Num:
{
delete[] s; // PATCH: mlkz
return ValToStr(ValC);
}
case Var:
{
delete[] s; // PATCH: mlkz
return CopyStr(pvar->name);
}

Discussion


Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.