| ▲ | Panzerschrek 3 hours ago | ||||||||||||||||||||||
That's why it's recommended to use size_t for passing sizes of buffers. It's unlikely to get overflow with it. In this particular case input buffer needs to have size larger than half of address space in order to trigger overflow, which isn't possible (64-bit systems usually have only 48 bits of actual address space, 32-bit systems don't allow allocating so large blocks). | |||||||||||||||||||||||
| ▲ | wahern 2 hours ago | parent | next [-] | ||||||||||||||||||||||
Not everybody recommends size_t. There's a sizeable community of people absolutely convinced most integers, including length and capacity integers, should be signed. And they stick to their guns even for C and C++. They have some very compelling logical arguments on their side, but IMO in languages like C and C++ they're just fatally unrealistic. | |||||||||||||||||||||||
| |||||||||||||||||||||||
| ▲ | m00dy 3 hours ago | parent | prev [-] | ||||||||||||||||||||||
never say never :) | |||||||||||||||||||||||