
BUG OF THE MONTH | Using memset to clear memory
static void freeMetaUI(gpointer p)
{
MakeMetaUI* ui = p;
tr_metaInfoBuilderFree(ui->builder);
g_free(ui->target);
memset(ui, ~0, sizeof(MakeMetaUI));
g_free(ui);
}
Warning V597 The compiler could delete the ‘memset’ function call, which is used to flush ‘ui’ object. The memset_s() function should be used to erase the private data. makemeta-ui.c:53
The most frequent mistake is to use the memset function to clear memory. In short, the compiler has every right to delete memset calls if it considers them meaningless. It usually happens when the buffer is cleared in the end of an operation and is no longer used.
Please click here to see more bugs from this project.