[flang-commits] [PATCH] D155224: [flang][unittests] Fix recent snprintf() changes to use correct buffer lengths
Peter Klausler via Phabricator via flang-commits
flang-commits at lists.llvm.org
Tue Jul 18 10:28:30 PDT 2023
This revision was automatically updated to reflect the committed changes.
Closed by commit rGecd691750648: [flang][unittests] Fix recent snprintf() changes to use correct buffer lengths (authored by klausler).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D155224/new/
https://reviews.llvm.org/D155224
Files:
flang/unittests/Decimal/quick-sanity-test.cpp
flang/unittests/Decimal/thorough-test.cpp
Index: flang/unittests/Decimal/thorough-test.cpp
===================================================================
--- flang/unittests/Decimal/thorough-test.cpp
+++ flang/unittests/Decimal/thorough-test.cpp
@@ -51,7 +51,8 @@
if (*q == '-' || *q == '+') {
++expo;
}
- std::snprintf(q + result.length, sizeof buffer, "e%d", expo);
+ std::snprintf(q + result.length,
+ buffer + sizeof buffer - (q + result.length), "e%d", expo);
}
const char *p{q};
auto rflags{ConvertDecimalToFloat(&p, &y, RoundNearest)};
Index: flang/unittests/Decimal/quick-sanity-test.cpp
===================================================================
--- flang/unittests/Decimal/quick-sanity-test.cpp
+++ flang/unittests/Decimal/quick-sanity-test.cpp
@@ -53,7 +53,8 @@
++expo;
}
if (q >= buffer && q < buffer + sizeof buffer) {
- std::snprintf(q + result.length, sizeof buffer, "e%d", expo);
+ std::snprintf(q + result.length,
+ buffer + sizeof buffer - (q + result.length), "e%d", expo);
}
const char *p{q};
auto rflags{ConvertDecimalToFloat(&p, &y, RoundNearest)};
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D155224.541627.patch
Type: text/x-patch
Size: 1151 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/flang-commits/attachments/20230718/f179d2dd/attachment-0001.bin>
More information about the flang-commits
mailing list