If mood_load() manages to load the mood but does not find any
admissible files, it does not deallocate the mood instance and does
not set up the global current_mood variable either. Plug the resulting
memory leak by destroying the mood also if there are no admissible
files (ret == 0).
ret = aa.m->stats.num;
mood_unload();
current_mood = aa.m;
+ ret = 1;
out:
free(aa.array);
- if (ret < 0)
+ if (ret <= 0) /* error, or no admissible files */
destroy_mood(aa.m);
return ret;
}