diff --git a/src/common/kernel/magic.c b/src/common/kernel/magic.c index 909489c4f..ee683436e 100644 --- a/src/common/kernel/magic.c +++ b/src/common/kernel/magic.c @@ -594,7 +594,7 @@ find_spellbyname(unit *u, char *name, const struct locale * lang) { spell_ptr *spt; sc_mage * m = get_mage(u); - spell * sp; + spell * sp = NULL; spell_names * sn; if (!m) return NULL; @@ -605,12 +605,13 @@ find_spellbyname(unit *u, char *name, const struct locale * lang) sn = get_spellnames(lang, m->magietyp); if (findtoken(&sn->names, name, (void**)&sp)!=E_TOK_NOMATCH) break; } - if (mtype==MAXMAGIETYP) return NULL; } - for (spt = m->spellptr; spt; spt = spt->next) { - if (sp->id==spt->spellid) return sp; - } + if (sp!=NULL) { + for (spt = m->spellptr; spt; spt = spt->next) { + if (sp->id==spt->spellid) return sp; + } + } if (lang==default_locale) return NULL; return find_spellbyname(u, name, default_locale); }