prnatid: Recover from getnatp() failure
cname() calls getnatp(), and returns a null pointer when it fails. Some systems (GNU, Windows) deal gracefully with printing null strings, others crash. Because we keep table EF_NATION entirely in memory, getnatp() should fail only on invalid country number. Rewrite prnatid() to catch this error and recover. Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
This commit is contained in:
parent
61a32b8b69
commit
44fbf6cd30
1 changed files with 5 additions and 1 deletions
|
@ -82,5 +82,9 @@ prnat(struct natstr *np)
|
||||||
char *
|
char *
|
||||||
prnatid(natid cnum)
|
prnatid(natid cnum)
|
||||||
{
|
{
|
||||||
return prbuf("%s (#%d)", cname(cnum), cnum);
|
struct natstr *np = getnatp(cnum);
|
||||||
|
|
||||||
|
if (CANT_HAPPEN(!np))
|
||||||
|
return prbuf("%d (#%d)", cnum, cnum);
|
||||||
|
return prnat(np);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue