memory errors in 376c8c65fcc33eb31541a971e6c8b7e9c2013f18 #3821
Comments
vexed changed priority from |
vexed changed blocking which not transferred by tractive |
vexed changed blockedby which not transferred by tractive |
vexed changed title from |
vexed commented This has nothing to do with VS2010. I'll do a quick fix shortly. |
vexed uploaded file |
vexed changed _comment0 which not transferred by tractive |
vexed commented Should work for all platforms. Reg312, you would leak memory by doing that. You can't just assign a byte array to a const char since the destructor is refs #3794 Broken in: |
Reg312 commented vexed, i know about memory leak in my solution, i just dont understand some things to find better way Tested patch: it works. stats was loaded without errors. |
NoQ commented Emm, but it's a stack variable. The destructor is called automatically when the function returns, right? |
Reg312 commented 2NoQ: may be i created QByteArray-variable and put it to some list, in that case i dont want destructor called. |
Per commented string.toUtf8().constData() gives you a temporary c-string reference that must be used immediately. QByteArray is allocated on the stack, and when it leaves scope it will call its own destructor, that's why there is no memory leaks with vexed's patch. However, I'd rather we used QString than QByteArray here. I should have caught this error during review. Sorry. Will commit fix. |
Per uploaded file Another fix based on QString, also fixes some more memory leaks. |
vexed commented It compiles and it don't crash, and looks saner. |
Reg312 commented tested fixmemorybug.diff - ok, compiles and properly load stats *just noticed oil derrick have 100$ price in master |
Per changed status from |
Per changed resolution from `` to |
Per commented Fixed in 97fe0b62b9ab206275c403be19bc483cbc8cdb98 |
resolution_fixed
type_bug
| by Reg312I'm using VS2010 for compiling warzone for my debug experiments
Source file stats.cpp was changed in latest commints in master-version (converting stats to ini)
since this changes i cannot run warzone, getting memory errors!
Also i found way to fix this memory erros
i just need add strdup() calls to places where QT string get converted to c-string
e.g.
weaponName = ini.value("turret").toString().toUtf8().constData();
weaponName = strdup(ini.value("turret").toString().toUtf8().constData());
after this changes i can run warzone.
Issue migrated from trac:3821 at 2022-04-16 10:44:31 -0700
The text was updated successfully, but these errors were encountered: