Skip to content

Warning, the NMEAParseError exception may break your code or exception handling routine #26

@Laro88

Description

@Laro88

The what() function should NOT be a std::string - this should be a const char* - the error handling in your code may be lead to bonkers code when the linker has special string handling in exceptions.

Here is a desc. of std::exception on cppreference
std::exception

Here is the inheriting NMEAParseError.

class NMEAParseError : public std::exception {
public:
	std::string message;
	NMEASentence nmea;

	NMEAParseError(std::string msg);
	NMEAParseError(std::string msg, NMEASentence n);
	virtual ~NMEAParseError();

	std::string what();
};

Sample code causing a seemingly innocent exception:

nmea::NMEAParser* p = new nmea::NMEAParser();
std::string s = "$GPRMC,094645.23,A,5724./1003,N,01036.32258,E,0.20,90.00,140225,000.1,W*68\r\n";
p->readSentence(s); //the / will cause a problem.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions