Skip to content

Commit

Permalink
Bug 1388789 - normalize null string handling in nsTextFormatter; r=fr…
Browse files Browse the repository at this point in the history
…oydnj

The char* and char16_t* cases handled null strings differently;
normalize them to both emit "(null)".

MozReview-Commit-ID: IzRkc3pSSjl
  • Loading branch information
tromey committed Sep 6, 2017
1 parent 52a90ac commit c0b0472
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions xpcom/string/nsTextFormatter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -454,6 +454,10 @@ int
nsTextFormatter::cvt_s(nsTextFormatter::SprintfStateStr* aState, const char* aStr, int aWidth,
int aPrec, int aFlags)
{
// Be sure to handle null the same way as %S.
if (aStr == nullptr) {
return cvt_S(aState, nullptr, aWidth, aPrec, aFlags);
}
NS_ConvertUTF8toUTF16 utf16Val(aStr);
return cvt_S(aState, utf16Val.get(), aWidth, aPrec, aFlags);
}
Expand Down

0 comments on commit c0b0472

Please sign in to comment.