<xloctime>: time_put::do_put does not handle EINVAL from _Wcsftime#1563
<xloctime>: time_put::do_put does not handle EINVAL from _Wcsftime#1563StephanTLavavej merged 13 commits intomicrosoft:mainfrom
<xloctime>: time_put::do_put does not handle EINVAL from _Wcsftime#1563Conversation
|
You need to set the invalid parameter handler to an actual function, not just |
Thank you for advice , I tried it, but it also makes tests failed |
|
I added the following handler, and tests/Dev11_0836436_get_time passed. Can you push the exact code you tried? |
Great! I'll try it later and if everything will be ok, there won't be any need to push my variant |
<xloctime>: time_put::do_put does not handle EINVAL from _Wcsftime`
<xloctime>: time_put::do_put does not handle EINVAL from _Wcsftime`<xloctime>: time_put::do_put does not handle EINVAL from _Wcsftime
CaseyCarter
left a comment
There was a problem hiding this comment.
Thanks for this bugfix that we took forever to review @futuarmo. Please let us know if you won't have time available to make the requested changes, and we'll polish up the PR and get it across the finish line.
|
FYI @amyw-msft @CaseyCarter, I pushed minor changes after you approved. |
|
@StephanTLavavej, thanks for fixes! I haven't time to do it in this several days |
|
I had to push an additional change to fix the internal test pass: |
|
Thanks for fixing this issue! 😸 🎉 🗓️ |
This PR fixes issue #1461
Error comes from
_Strftimeand_Wcsftime,_Countbecomes 0 and we should stop execution and setios_base::badbitif_Count == 0.do_putis called afteroperator<<So, we can change
_Ostrstate only here according to standard function definitionI tried to pass
_Stateas a parameter toputmethod and it works perfectly, but it contrary to standard and, as I understand, it will be ABI break.Also I tried to invalidate iterator in
do_putmethod, it works withwstringstream, but doesn't works withsstringstream:do_putmethod part:I realize that it's wrong decision.
So, in my opinion the only way to fix it is to do something like that (it works too):
operator<<iniomanipheaderAnd then set state to badbit in case if ucrt returns error (0):
Modified part of
do_put:But this decision is not so elegant. Please review it and give some another opinion on this
Also, I added test for this case, but
ucrtreturns and error, tests become failed and error message appears. I tried to set_set_invalid_parameter_handlerto NULL and empty function but it doesn't help. Please, help to avoid it.