Summary:
This has been bothering me for a while when I've been trying to
verify builds with clang. This generates a ton of spew and the current
code can't actually handle non-default negatives so let's just throw if
we see one.
Test Plan: fbmake runtests
Reviewed By: meyering@fb.com
Subscribers: mathieubaudet, njormrod, folly-diffs@, bmatheny, benyluo, shikong, kmdent, fma, ranjeeth, subodh
FB internal diff:
D1643881
Signature: t1:
1643881:
1414523777:
085035ce8c280fbd6481b2ce0354b53b96fdc50e
template <class FormatCallback>
void formatString(StringPiece val, FormatArg& arg, FormatCallback& cb) {
+ if (arg.width != FormatArg::kDefaultWidth && arg.width < 0) {
+ throw BadFormatArg("folly::format: invalid width");
+ }
+ if (arg.precision != FormatArg::kDefaultPrecision && arg.precision < 0) {
+ throw BadFormatArg("folly::format: invalid precision");
+ }
+
if (arg.precision != FormatArg::kDefaultPrecision &&
val.size() > arg.precision) {
val.reset(val.data(), arg.precision);