Fix cpp crash