Search code examples
csanitization

What is address sanitization in C?


Sanitization keeps code clean, removing the "dirty" injections. In HTML and JavaScript, this is accomplished by removing unsafe tags or escaping user input.

What does "sanitization" mean to C?


Solution

  • It's a compiler feature (at least in Clang) that tries to detect memory addresses that are invalid, such as those that are out-of-bounds, or that are still being used after they are freed.

    You can enable it with the -fsanitize=address compiler flag. See here for more info.