summaryrefslogtreecommitdiff
path: root/source/y/bsd-games/patches/0017-hack-Fix-segv-when-i-inventory-done-after-load-from-.patch
diff options
context:
space:
mode:
Diffstat (limited to 'source/y/bsd-games/patches/0017-hack-Fix-segv-when-i-inventory-done-after-load-from-.patch')
-rw-r--r--source/y/bsd-games/patches/0017-hack-Fix-segv-when-i-inventory-done-after-load-from-.patch67
1 files changed, 67 insertions, 0 deletions
diff --git a/source/y/bsd-games/patches/0017-hack-Fix-segv-when-i-inventory-done-after-load-from-.patch b/source/y/bsd-games/patches/0017-hack-Fix-segv-when-i-inventory-done-after-load-from-.patch
new file mode 100644
index 00000000..51116aee
--- /dev/null
+++ b/source/y/bsd-games/patches/0017-hack-Fix-segv-when-i-inventory-done-after-load-from-.patch
@@ -0,0 +1,67 @@
+From: "Dr. Tobias Quathamer" <toddy@debian.org>
+Date: Sat, 28 Apr 2018 15:09:16 +0200
+Subject: hack: Fix segv when 'i' (inventory) done after load from saved game.
+
+Not all name information was saved or recovered leaving pointers to
+nothing.
+
+Thanks: Richard Henschel <rhenschel@accesscomm.ca>
+---
+ hack/hack.o_init.c | 25 +++++++++++++++++++++++--
+ 1 file changed, 23 insertions(+), 2 deletions(-)
+
+diff --git a/hack/hack.o_init.c b/hack/hack.o_init.c
+index dc5bf93..fdab26e 100644
+--- a/hack/hack.o_init.c
++++ b/hack/hack.o_init.c
+@@ -184,8 +184,7 @@ savenames(fd)
+ bwrite(fd, (char *) bases, sizeof bases);
+ bwrite(fd, (char *) objects, sizeof objects);
+ /*
+- * as long as we use only one version of Hack/Quest we need not save
+- * oc_name and oc_descr, but we must save oc_uname for all objects
++ * Save oc_name, oc_descr, as well as oc_uname for all objects
+ */
+ for (i = 0; i < SIZE(objects); i++) {
+ if (objects[i].oc_uname) {
+@@ -193,6 +192,16 @@ savenames(fd)
+ bwrite(fd, (char *) &len, sizeof len);
+ bwrite(fd, objects[i].oc_uname, len);
+ }
++ if (objects[i].oc_name) {
++ len = strlen(objects[i].oc_name) + 1;
++ bwrite(fd, (char *) &len, sizeof len);
++ bwrite(fd, objects[i].oc_name, len);
++ }
++ if (objects[i].oc_descr) {
++ len = strlen(objects[i].oc_descr) + 1;
++ bwrite(fd, (char *) &len, sizeof len);
++ bwrite(fd, objects[i].oc_descr, len);
++ }
+ }
+ }
+
+@@ -205,11 +214,23 @@ restnames(fd)
+ mread(fd, (char *) bases, sizeof bases);
+ mread(fd, (char *) objects, sizeof objects);
+ for (i = 0; i < SIZE(objects); i++)
++ {
+ if (objects[i].oc_uname) {
+ mread(fd, (char *) &len, sizeof len);
+ objects[i].oc_uname = (char *) alloc(len);
+ mread(fd, objects[i].oc_uname, len);
+ }
++ if (objects[i].oc_name) {
++ mread(fd, (char *) &len, sizeof len);
++ objects[i].oc_name = (char *) alloc(len);
++ mread(fd, objects[i].oc_name, len);
++ }
++ if (objects[i].oc_descr) {
++ mread(fd, (char *) &len, sizeof len);
++ objects[i].oc_descr = (char *) alloc(len);
++ mread(fd, objects[i].oc_descr, len);
++ }
++ }
+ }
+
+ int