http://bugs.winehq.org/show_bug.cgi?id=20232
--- Comment #12 from Jörg Höhle hoehle@users.sourceforge.net 2010-05-19 23:46:18 --- The call of WAVE_mciOpenFile within WAVE_mciSave causes several memory leaks in winmm/mci.c and mciwave.c that Valgrind detects in winmm/tests/mci.c.
Yet I'm not much inclined to patch WAVE_mciReadFmt to fix the one leak in mciwave (wmw->lpWaveFormat) because I feel that calling OpenFile within MCI_SAVE is somehow bogus and should be changed anyway. a) It causes state to be lost which the native MCI does not loose, e.g. status position (verified by tests I once performed). b) Using mmioClose in Save leaves the driver in an inconsistent state should anything fail afterwards (in particular mciOpenFile). Or if save itself fails, the device is gone (save "X:\nosuchdevice"; play => MCIERR_FILE_NOT_FOUND -- imagine your text editor loosing your text when trying to save).
I'm not convinced that the current use of MMIO within mciwave is "the right thing". It is not easy to implement MCI_RECORD_INSERT (which is the default in native, not MCI_RECORD_OVERWRITE) and MCI_DELETE (section within file, see tests/mci.c) with it, but I'm not familiar with MMIO.
Native mciwave's Record command behaves like a text editor: you can insert and delete things at arbitrary positions.