log: fix a memory leak in log handling

This path is never hit but the code is incorrect, nevertheless.