bugClanLib - Bugs: bug #5586, CL_Sprite(const std::string...

 
 

bug #5586: CL_Sprite(const std::string &resource_id, CL_ResourceManager *manager) constructor causes SIGSEGV

Submitter:  Invalid User ID <#22609>
Submitted:  Sat 27 Sep 2003 03:59:44 AM UTC
   
 
Category:  clanDisplay Severity:  3 - Normal
Item Group:  Crash Error Status:  None
Privacy:  Public Assigned to:  None
Open/Closed:  Open Release:  0.7.4
Operating System:  GNU/Linux Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Sat 27 Sep 2003 03:59:44 AM UTC, original submission:  

resource.getdata() can fail and return a null pointer. data->get_sprite will then cause a segmentation violation. Should check validity of pointer before using it. Something like:

if ( data )
    {
    impl = new CL_Sprite_Generic;
    *impl = *data->get_sprite().impl;
    }
else
    {
    //
    // Throw an exception.
    //
    }

Below is the code in question.

---------------------------------------------
CL_Sprite::CL_Sprite(const std::string &resource_id, CL_ResourceManager *manager)
: impl(0)
{
    resource = manager->get_resource(resource_id);
    resource.load();
   
    CL_ResourceData_Sprite *data =
    (CL_ResourceData_Sprite *) resource.get_data("sprite");
   
    impl = new CL_Sprite_Generic;
    *impl = *data->get_sprite().impl; <--- here
   
    restart();
}

Invalid User ID <#22609>

 

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

Attach Files:
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

CC list is empty

 

There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

Only logged-in users can vote.

 

No changes have been made to this item

Back to the top

Powered by Savane 3.13-d3ae.
Corresponding source code