Avoid signed integer overflow in string offset check Cast to size_t before performing operations instead of afterwards.