Fix potential codec leak when USE_DCMTK is ON.