diff options
author | Patrick J Volkerding <volkerdi@slackware.com> | 2019-02-17 23:44:53 +0000 |
---|---|---|
committer | Eric Hameleers <alien@slackware.com> | 2019-02-18 08:59:47 +0100 |
commit | 66b0761fe7bfe43a58a4a7c3012ff3a46acf2e69 (patch) | |
tree | 78c6718616f92d2ec4d90386b24f911487e60bba /source/y/bsd-games/patches/0017-hack-Fix-segv-when-i-inventory-done-after-load-from-.patch | |
parent | a576ec7a0e6c880029328d465402520ee1c20571 (diff) | |
download | current-66b0761fe7bfe43a58a4a7c3012ff3a46acf2e69.tar.gz |
Sun Feb 17 23:44:53 UTC 201920190217234453
ap/cups-filters-1.22.1-x86_64-1.txz: Upgraded.
y/bsd-games-2.17-x86_64-1.txz: Upgraded.
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-.patch | 67 |
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 |