From 2432b5c2706d052d95fe78c85aa8b55df5083c51 Mon Sep 17 00:00:00 2001 From: andrei <68240139+andrei8l@users.noreply.github.com> Date: Mon, 25 Apr 2022 01:32:47 +0300 Subject: [PATCH] item: fix magazine_default for null ammo (#57115) --- src/item.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/item.cpp b/src/item.cpp index 13c17d1c744fd..72502a2b2eaa7 100644 --- a/src/item.cpp +++ b/src/item.cpp @@ -10319,8 +10319,8 @@ bool item::uses_magazine() const itype_id item::magazine_default( bool conversion ) const { // consider modded ammo types - if( conversion && !ammo_types().empty() ) { - const itype_id ammo = ammo_default(); + itype_id ammo; + if( conversion && ( ammo = ammo_default(), !ammo.is_null() ) ) { for( const itype_id &mag : contents.magazine_compatible() ) { auto mag_types = mag->magazine->type; if( mag_types.find( ammo->ammo->type ) != mag_types.end() ) {