Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gregorian istream exception with empty input #225

Open
lakeweb opened this issue Dec 10, 2022 · 0 comments
Open

Gregorian istream exception with empty input #225

lakeweb opened this issue Dec 10, 2022 · 0 comments

Comments

@lakeweb
Copy link

lakeweb commented Dec 10, 2022

I'm using boost::lexical cast to process xml data. The likes of:

template<typename T>
bool GetAttribute(const pugi::char_t* name, T& attr) const {
    try {
        attr = boost::lexical_cast<T>(GetAttribute(name));
    }
    catch (boost::bad_lexical_cast& e) {
        std::cout << "pugi: " << e.what() << std::endl;
        return false;
    }
    return true;
}

Which works fine even if there is a bad str like "0". Nice that it leaves whatever default value in attr alone. If this is a new node that does not exist yet, 'GetAttribute(name)' return an empty char* str, "". It is a valid string but instead of throwing it gets down parse_date and:

format_date_parser.hpp(258)
while(std::isspace(*sitr) && sitr != stream_end) { ++sitr; }
But sitr is not a valid pointer if the input was an empty string. The buffer pointers don't get set up. For now, I'm hacking this code, checking that 'sitr' is not null, and throwing if it is. I'm just thinking that should be part of the Gregorian parser. And I don't know but this may have never really shown because linux std_libs::istream hand you a valid pointer in this circumstance.

Best, Dan.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant