server: Avoid use of uninitialized memory.
change_current_mood() receives an errmsg pointer which the callers
expect to be initialized with an error string if (and only if) the
function returns negative.
However, most error paths miss to initialize the pointer which results
in undefined behaviour in the caller which attempts to free(3)
uninitialized memory. The gcc AddressSanitizer and valgrind both
catch this:
gcc:
==14788==ERROR: AddressSanitizer: attempting free on address which was not malloc()-ed: 0x081af250 in thread T0
valgrind:
==4410== Invalid free() / delete / delete[] / realloc()
The bug was introduced half a year ago when version 2 moods were
introduced in commit
3d3a2f50.