Memory leak bug fixed in the read_mdat() function