sledge icon indicating copy to clipboard operation
sledge copied to clipboard

GenericStructure.ParseStructure enters infinite loop on unexpected EOF

Open quantumdude836 opened this issue 10 years ago • 1 comments

Sledge.Providers/GenericStructure.cs:635 - if reader doesn't have any more data, it returns null. String.IsNullOrWhiteSpace(null) is true, so the loop will never end. You could add something like:

if (line == null)
    throw new WhateverException("EOF trying to parse generic structure");

For reference, materials/models/gibs/combine_helicopter_gibs/combine_helicopter02.vmt from Half-Life 2: Episode Two has an extra 's' in it.

quantumdude836 avatar May 12 '15 01:05 quantumdude836

This bug still exists in the new release, the new file location is SerialisedObjectFormatter.cs:122

This example code replicates the bug:

var invalid = "Invalid\n{\ns";

var ms = new MemoryStream(Encoding.ASCII.GetBytes(invalid));
var fmt = new SerialisedObjectFormatter();
fmt.Deserialize(ms).Dump();

The invalid VMT has since been patched in HL2 EP2.

LogicAndTrick avatar Sep 08 '18 07:09 LogicAndTrick