Don't know how practical it is to find such an issue, but here's the code with/without the error -- dereferencing in the free() doesn't match dereferencing in the strdup().
receive_device_info_bad_free() may return a free'd pointer, but only in case the return value is -1. So that should be checked.
Cppcheck can't prove that any UB will happen here.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Don't know how practical it is to find such an issue, but here's the code with/without the error -- dereferencing in the free() doesn't match dereferencing in the strdup().
receive_device_info_bad_free()
may return a free'd pointer, but only in case the return value is -1. So that should be checked.Cppcheck can't prove that any UB will happen here.