Opened 2 years ago

Closed 22 months ago

#916 closed defect (fixed)

RasdlError class should not have errno member

Reported by: dmisev Owned by: jzhang
Priority: major Milestone: 9.1
Component: rasdl Version: development
Keywords: Cc: pbaumann
Complexity: Medium

Description

The class RasdlError? (in rasdl_error.(hh|cc) has a member called "errno". In C++ errno is a macro reserved for error handling (see http://tinyurl.com/3uxzfls).

Since rasdl_error.cc/hh includes no standard headers the code compiles just fine. But when rasdl_error.hh is included in some file that already included standard headers the preprocessor transforms RasdlError? into:

class RasdlError
{
  public:
    RasdlError( unsigned int e );
    virtual ~RasdlError();
    virtual const char * what();
  private:
    unsigned int (*__errno_location ());
};

So the class layout changes since unsigned int (*errno_location()); takes no space. Therefore all methods operating on errno are accessing memory that doesn´t belong to the object. This caused rasdl to crash when called with an unknown parameter (e.g. rasdl -g).

Changing the members name to error_code fixed the problem.

Change History (2)

comment:1 Changed 23 months ago by dmisev

  • Owner changed from dmisev to jzhang
  • Status changed from new to assigned

comment:2 Changed 22 months ago by dmisev

  • Resolution set to fixed
  • Status changed from assigned to closed
Note: See TracTickets for help on using tickets.