Patch device.cpp to avoit PatList memory leak