bugGlobulation 2 - Bugs: bug #28074, Invalid access to memory

 
 

bug #28074: Invalid access to memory

Submitted by:  Karel Klic <kklic>
Submitted on:  Sun 22 Nov 2009 04:40:20 PM UTC  
 
Severity: 3 - NormalStatus: None
Assigned to: NoneOpen/Closed: Closed
Release: mercurialOperating System: None

Add a New Comment(Rich Markup)
   

You are not logged in

Please log in, so followups can be emailed to you.

 

Thu 03 Nov 2011 05:07:35 AM UTC, comment #3:

This very code has been changed and we didn't get info in 2 years. closing.

Leo Wandersleb <giszmo>
Project Member
Sat 26 Dec 2009 09:33:54 AM UTC, comment #2:

Not exactly. The return pointer is to the internal storage of a std::string in the string table, which should be unmutable during the game execution, so it is valid (albeit ugly) to access it. Can you give more information about the crash you experienced? Thank you.

Stephane Magnenat <nct>
Project Administrator
Sat 12 Dec 2009 12:07:14 AM UTC, comment #1:

Checked the code at the line you entered, but after recent changes to the code the thing you mention seems to be gone. Replaced all cha ptr's to std::string, well Giszmo did and I guess he corrected it then.

Linus Probert <liquidityc>
Project Member
Sun 22 Nov 2009 04:40:20 PM UTC, original submission:

There is an error in libgag/src/StringTable.cpp

line 308
function const char StringTable::getString(const char stringname)

It should be more like:

- return getString(key).c_str();
+ static std::string result;
+ result = getString(key);
+ return result.c_str();

So the returned value is valid until this function is called next time.

In the current code the std::string returned by getString(key) is destroyed at the end of this function, but its content is returned by c_str() as a result of this function.

Karel Klic <kklic>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach File(s):
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -unavailable- added by giszmo (Posted a comment)
  • -unavailable- added by nct (Posted a comment)
  • -unavailable- added by liquidityc (Posted a comment)
  • -unavailable- added by kklic (Submitted the item)
  •  

    Do you think this task is very important?
    If so, you can click here to add your encouragement to it.
    This task has 0 encouragements so far.

    Only logged-in users can vote.

     

    Please enter the title of George Orwell's famous dystopian book (it's a date):

     

     

    Follows 1 latest change.

    Date Changed By Updated Field Previous Value => Replaced By
    Thu 03 Nov 2011 05:07:35 AM UTCgiszmoOpen/ClosedOpen=>Closed

    Back to the top


    Powered by Savane 3.1-cleanup1