Bug#1003064: xshisen: cannot show the personal score
Package: xshisen
Version: 1:1.51-7
Severity: normal
Tags: patch
Dear Maintainer,
xshisen (amd64) crashes when trying to show the personal score.
How to repeat
-------------
(1) If you have no ~/.xshisen.scores file, play the game once.
(2) Select Menu: Game -> Personal Score
or
hit Ctrl-t.
Analysis
--------
It crashes in Score::PersonalStat(int) by segmentation fault.
>From the build log
>score.C: In member function ‘int Score::PersonalStat(int)’:
>score.C:622:1: warning: control reaches end of non-void function [-Wreturn-type]
> 622 | }
> | ^
According to the GCC manual, this causes undefined behavior.
So it may crash.
https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html
> -Wreturn-type
(snip)
> Unlike in C, in C++, flowing off the end of a non-void function other than
> main results in undefined behavior even when the value of the function is
> not used.
How to fix
----------
Inserting "return 0;" at the end of this function fixes this problem.
----- Begin
--- xshisen-1.51.orig/score.C
+++ xshisen-1.51/score.C
@@ -619,6 +619,7 @@ Score::PersonalStat(int kind_of_game)
bufp += strlen(bufp);
*bufp = '\0';
Popup(buf);
+ return 0;
}
int
----- End
Regards,
Nobuhiro Ban
-- System Information:
Debian Release: bookworm/sid
APT prefers testing-debug
APT policy: (500, 'testing-debug'), (500, 'stable-security'), (500,
'stable-debug'), (500, 'testing'), (500, 'stable')
Architecture: amd64 (x86_64)
Kernel: Linux 5.15.0-2-amd64 (SMP w/4 CPU threads)
Kernel taint flags: TAINT_FIRMWARE_WORKAROUND
Locale: LANG=ja_JP.UTF-8, LC_CTYPE=ja_JP.UTF-8 (charmap=UTF-8), LANGUAGE not set
Shell: /bin/sh linked to /bin/dash
Init: systemd (via /run/systemd/system)
LSM: AppArmor: enabled
Versions of packages xshisen depends on:
ii libc6 2.33-1
ii libgcc-s1 11.2.0-13
ii libstdc++6 11.2.0-13
ii libx11-6 2:1.7.2-2+b1
ii libxm4 2.3.8-3
ii libxpm4 1:3.5.12-1
ii libxt6 1:1.2.0-1
xshisen recommends no packages.
xshisen suggests no packages.
-- debconf-show failed
Reply to: