Skip to content

Commit

Permalink
Add a safety check in Compositor.Update(). (#27)
Browse files Browse the repository at this point in the history
  • Loading branch information
ShikiSuen authored Dec 1, 2023
1 parent 7866aa1 commit 6d90168
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 7 deletions.
2 changes: 1 addition & 1 deletion Megrez.Tests/Megrez.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<TargetFramework>net6.0</TargetFramework>
<Nullable>enable</Nullable>
<IsPackable>false</IsPackable>
<ReleaseVersion>2.7.1</ReleaseVersion>
<ReleaseVersion>2.7.2</ReleaseVersion>
</PropertyGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion Megrez.sln
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,6 @@ Global
$0.DotNetNamingPolicy = $4
$4.DirectoryNamespaceAssociation = PrefixedHierarchical
$0.StandardHeader = $5
version = 2.7.1
version = 2.7.2
EndGlobalSection
EndGlobal
8 changes: 4 additions & 4 deletions Megrez/Megrez.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<Nullable>enable</Nullable>
<ReleaseVersion>2.7.1</ReleaseVersion>
<ReleaseVersion>2.7.2</ReleaseVersion>
<PackageId>vChewing.Megrez</PackageId>
<Authors>Shiki Suen</Authors>
<Company>Atelier Inmu</Company>
<Copyright>(c) 2022 and onwards The vChewing Project for Megrez-specific changes; (c) 2022 and onwards Lukhnos Liu for upstream contents.</Copyright>
<RepositoryUrl>https://github.com/ShikiSuen/MegrezNT</RepositoryUrl>
<NeutralLanguage>zh-TW</NeutralLanguage>
<AssemblyVersion>2.7.1</AssemblyVersion>
<FileVersion>2.7.1</FileVersion>
<Version>2.7.1</Version>
<AssemblyVersion>2.7.2</AssemblyVersion>
<FileVersion>2.7.2</FileVersion>
<Version>2.7.2</Version>
<Product>Megrez</Product>
<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
<PackageReadmeFile>README.md</PackageReadmeFile>
Expand Down
3 changes: 2 additions & 1 deletion Megrez/src/1_Compositor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -446,7 +446,8 @@ public int Update(bool updateExisting = false) {
foreach (int position in range) {
foreach (int theLength in new BRange(1, Math.Min(MaxSpanLength, range.Upperbound - position) + 1)) {
List<string> joinedKeyArray = GetJoinedKeyArray(new(position, position + theLength));
Node? theNode = GetNodeAt(position, theLength, joinedKeyArray);
BRange safeLocationRange = new BRange(0, Spans.Count);
Node? theNode = safeLocationRange.Contains(position) ? GetNodeAt(position, theLength, joinedKeyArray) : null;
if (theNode is {}) {
if (!updateExisting) continue;
List<Unigram> unigramsA = TheLangModel.UnigramsFor(joinedKeyArray);
Expand Down

0 comments on commit 6d90168

Please sign in to comment.