================
@@ -294,13 +294,15 @@ bool Context::evaluateStrlen(State &Parent, const Expr
*E, uint64_t &Result) {
if (!FieldDesc->isPrimitiveArray())
return false;
- if (Ptr.isDummy() || Ptr.isUnknownSizeArray())
+ if (Ptr.isDummy() || Ptr.isUnknownSizeArray() || Ptr.isPastEnd())
return false;
unsigned N = Ptr.getNumElems();
if (Ptr.elemSize() == 1) {
- Result = strnlen(reinterpret_cast<const char *>(Ptr.getRawAddress()), N);
- return Result != N;
+ unsigned Size = N - Ptr.getIndex();
----------------
ojhunt wrote:
It is not possible to hit this in the new interpreter prior to this change, the
existing code fails to handle out of bounds pointer into a string literal (or
presumably any array), or an in bounds offset.
It feels like it should be in a different PR, but because it can't currently be
hit it can't be tested?
https://github.com/llvm/llvm-project/pull/173140
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits