[Scummvm-git-logs] scummvm master -> f9f1a3cbabf8fbebc4dc331c7a85e0392f2b982a

bluegr noreply at scummvm.org
Sun Jun 30 11:19:25 UTC 2024


This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
f9f1a3cbab AGS: Parser fixes from upstream


Commit: f9f1a3cbabf8fbebc4dc331c7a85e0392f2b982a
    https://github.com/scummvm/scummvm/commit/f9f1a3cbabf8fbebc4dc331c7a85e0392f2b982a
Author: mausimus (73635663+mausimus at users.noreply.github.com)
Date: 2024-06-30T14:19:21+03:00

Commit Message:
AGS: Parser fixes from upstream

Compilation of three bug fixes to text parser I recently made in the AGS project, around alternatives syntax:
1. Stop parsing when reaching end during alternatives skipping (causing an out-of-bounds memory read)
2. Correctly skip over multi-word alternatives (incorrect parsing of alternative lists)
3. Use dedicated function to identify word boundaries (affecting dash and apostrophe containing alternatives)

Upstream commits (release-3.6.1 branch):
1. 17f8ea2f0efadec7b3696d4ba51733f1cddc0772 (check for end of input not to go beyond)
2. e98315393a34629b8935fdee7bd725a8299f941c (fix multi-word alternative skipping)
3. 9b0ccbd04e36e757392b1fc744919c785310c57b (consistently check for word boundaries)

Changed paths:
    engines/ags/engine/ac/parser.cpp


diff --git a/engines/ags/engine/ac/parser.cpp b/engines/ags/engine/ac/parser.cpp
index 4884a962a78..bc54eaebe62 100644
--- a/engines/ags/engine/ac/parser.cpp
+++ b/engines/ags/engine/ac/parser.cpp
@@ -242,8 +242,13 @@ int parse_sentence(const char *src_text, int *numwords, short *wordarray, short
 						const char *textStart = ++text; // begin with next char
 
 						// find where the next word ends
-						while ((text[0] == ',') || (Common::isAlnum((unsigned char)text[0]) != 0))
-							text++;
+						while ((text[0] == ',') || is_valid_word_char(text[0])) {
+							// shift beginning of potential multi-word each time we see a comma
+							if (text[0] == ',')
+								textStart = ++text;
+							else
+								text++;
+						}
 
 						continueSearching = 0;
 
@@ -251,8 +256,11 @@ int parse_sentence(const char *src_text, int *numwords, short *wordarray, short
 							Common::strcpy_s(thisword, textStart);
 							thisword[text - textStart] = 0;
 							// forward past any multi-word alternatives
-							if (FindMatchingMultiWordWord(thisword, &text) >= 0)
+							if (FindMatchingMultiWordWord(thisword, &text) >= 0) {
+								if (text[0] == 0)
+									break;
 								continueSearching = 1;
+							}
 						}
 					}
 




More information about the Scummvm-git-logs mailing list