[bugfix] segmentation fault due to double free