[clang] [Clang] Implement the 'counted_by' attribute (PR #76348)

Kees Cook via cfe-commits cfe-commits at lists.llvm.org
Tue Jan 9 09:46:44 PST 2024


kees wrote:

> > This prints a wrapped calculation instead of the expected "0".
> 
> Shouldn't `getDefaultBuiltinObjectSizeResult` return `-1`? Have you tried `-2` to see if it's returning the negative count value or it happens to be equal to the default value?

Well, maybe it's not wrapped, but it should absolutely return 0, not -1. The return value of -1 means "I don't know how large this is". In this case we _do_ know, but it's nonsense, so we must return 0 so that anything checking lengths will not write anything to the array.

https://github.com/llvm/llvm-project/pull/76348


More information about the cfe-commits mailing list