2 ms·
Which it does, if such use is on any control flow path after the free(). For example, bool first = true; while (f()) { if (first) free(p); firs
by WalterBright 7y ago
Which it does, if such use is on any control flow path after the free(). For example,
bool first = true;
while (f()) {
if (first) free(p);
first = false;
}
is rejected as double-free.
- deleted 7y ago[deleted]
- bonzini 7y agoWhat about while (f()) { free(p); p = NULL; }
- WalterBright 7y agoIt'll compile because although free(p) consumes p and p is undefined immediately afterwards, p then becomes defined again via the assignment and so the while loop always enters with a defined value for p.