by 30thElement · 12y ago · 0 comments
char* plain_text = malloc(size);
///do stuff with plain_text
memset(plain_text, 0, size);
free(plain_text);
For most programs that last memset is unnecessary (and may even be unnecessary according to the standard, but it's probably implementation defined, not undefined behavior) and it makes sense for the compiler to optimize it away. But for crypto purposes you have to be afraid of someone being able to read plain_text later, so the memset is important