It is alway appropiate to free 'str' so remove the if-check.
Use clang's static analyzer, scan-build, to find the problem and later to show resolution.
The change looks good to me but it isn't my area. Add Peter.
It breaks pci_emul in other places, needs further investigation.
I'm taking it.
It looks like the original code was correct. Is there any reason to keep this review open?
Concur, but not sure how to force it closed.