Skip to content

Commit

Permalink
GRF: Add an error check for empty RSM node names
Browse files Browse the repository at this point in the history
Some of them are just the empty string. Decoding them throws with an iconv error ("Invalid argument"). Shouldn't affect cdata.
  • Loading branch information
rdw-software committed Feb 18, 2024
1 parent 357e064 commit b81af26
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
4 changes: 4 additions & 0 deletions Core/FileFormats/RagnarokGRF.lua
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,10 @@ function RagnarokGRF:DecodeFileEntries()
end

function RagnarokGRF:DecodeFileName(input)
if input == "" then
return input
end

-- This should likely be moved since it won't happen at decoding time, only on demand (in other decoders)
if type(input) == "string" then
local unicodeFilePath, err = iconv.convert(input, "CP949", "UTF-8")
Expand Down
4 changes: 4 additions & 0 deletions Tests/FileFormats/RagnarokGRF.spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -410,5 +410,9 @@ describe("RagnarokGRF", function()
local pointerToNullTerminatedStringBytes = inputBuffer:ref()
assertEquals(RagnarokGRF:DecodeFileName(pointerToNullTerminatedStringBytes), "hello/world.txt")
end)

it("should return empty strings unchanged", function()
assertEquals(RagnarokGRF:DecodeFileName(""), "")
end)
end)
end)

0 comments on commit b81af26

Please sign in to comment.