▲ | Karrot_Kream 3 days ago | ||||||||||||||||
Memory safe doesn't mean protection from integer overflow unless you use that integer to index into some array. I'm not sure how you'd enter NULL given scanf. | |||||||||||||||||
▲ | Voultapher 3 days ago | parent [-] | ||||||||||||||||
I'm not sure how showing that gp can't even write a dozen lines of memory safe C proves that doing so for the exponentially harder 100+k LoC projects is feasible. The program contains potential use of uninitialized memory UB, because scanf error return is not checked and num1 and num2 are not default initialized. And a + b can invoke signed integer overflow UB. A program with more than zero UB cannot be considered memory safe. For example if the program runs in a context where stdin can't be read scanf will return error codes and leave the memory uninitialized. | |||||||||||||||||
|