-
Notifications
You must be signed in to change notification settings - Fork 72
[GEN][ZH] Demote throw to assert in AsciiString::format_va, UnicodeString::format_va #835
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
Conversation
throw ERROR_OUT_OF_MEMORY; | ||
set(buf); | ||
validate(); | ||
const int result = _vsnprintf(buf, sizeof(buf)/sizeof(WideChar)-1, format, args); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sizeof(char)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ups. Fixed.
const int result = _vsnprintf(buf, sizeof(buf)/sizeof(WideChar)-1, format, args); | ||
if (result >= 0) | ||
{ | ||
set(buf); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we set buf[MAX_FORMAT_BUF_LEN-1] = 0; while we are at it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Regarding _vsnprintf & _snprintf, I planned to do another change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good
This change demotes the unnecessary throw to debug assert in AsciiString::format_va and UnicodeString::format_va. Unnecessary throw because this format error is not necessarily a fatal error that needs to terminate the process. The program may just run fine with this error. The debug assert is enough to see the error.
Original
This change