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

Possibly incorrect downcasting of separator_ #89

Closed
sffc opened this issue Feb 27, 2019 · 2 comments
Closed

Possibly incorrect downcasting of separator_ #89

sffc opened this issue Feb 27, 2019 · 2 comments
Assignees

Comments

@sffc
Copy link
Contributor

sffc commented Feb 27, 2019

The template type Iterator is used throughout double-conversion.cpp. It appears that Iterator can be one of two types:

  • const uc16*
  • const char*

There is a function Advance whose signature is:

template<class Iterator>
static bool Advance (Iterator* it, char separator, int base, Iterator& end)

The call sites look like this:

// current is of type Iterator
Advance(&current, separator_, 10, end)

The problem is that separator_ is being downcast to a char even when using the uc16* template type for the string. The implication is that there is a possible loss of information; for example, the separator might be a Unicode code point that doesn't fit in a char. A great real-life example could be 'NARROW NO-BREAK SPACE' (U+202F), which is now used in CLDR as the default grouping separator in France.

The code should be checked to ensure that separator_ is not downcast to a char unless the iterator is a char iterator.

@floitsch
Copy link
Collaborator

Will look into it.
Don't hesitate to ping from time to time (~ once a week?) to make sure I don't forget.

@sffc
Copy link
Contributor Author

sffc commented Mar 4, 2019

Thank you!

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

2 participants