From ccfa54524b4ef4f6907fc3ebf2f2c903c2b992a8 Mon Sep 17 00:00:00 2001 From: nooperation Date: Wed, 12 Mar 2025 23:43:00 -0400 Subject: [PATCH] Fixed crash in BVHDecoder - ReadBytesUntilNull was reading until newline instead of null Fixed crash in PrimMesher - Profile::Copy was not copying correctly Fixed crash in PrmiMesher - SculptMap::ScaleImage was disposing live SKBitmap's --- LibreMetaverse/BVHDecoder.cs | 2 +- PrimMesher/PrimMesher.cs | 4 +++- PrimMesher/SculptMap.cs | 10 +++++++++- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/LibreMetaverse/BVHDecoder.cs b/LibreMetaverse/BVHDecoder.cs index e3f344d9..58bc88d7 100644 --- a/LibreMetaverse/BVHDecoder.cs +++ b/LibreMetaverse/BVHDecoder.cs @@ -181,7 +181,7 @@ namespace OpenMetaverse for (var j = i; j < data.Length; j++) { char spot = Convert.ToChar(data[j]); - if (spot == '\n') + if (spot == '\0') { endpos = j; break; diff --git a/PrimMesher/PrimMesher.cs b/PrimMesher/PrimMesher.cs index 09a33a71..c9481817 100644 --- a/PrimMesher/PrimMesher.cs +++ b/PrimMesher/PrimMesher.cs @@ -1058,7 +1058,9 @@ namespace LibreMetaverse.PrimMesher if (needFaces) copy.faces.AddRange(faces); - if (copy.calcVertexNormals == calcVertexNormals) + + copy.calcVertexNormals = calcVertexNormals; + if (calcVertexNormals) { copy.vertexNormals.AddRange(vertexNormals); copy.faceNormal = faceNormal; diff --git a/PrimMesher/SculptMap.cs b/PrimMesher/SculptMap.cs index 35566005..28a13fa1 100644 --- a/PrimMesher/SculptMap.cs +++ b/PrimMesher/SculptMap.cs @@ -121,6 +121,10 @@ namespace LibreMetaverse.PrimMesher } catch (Exception e) { + if (needsScaling) + { + bm.Dispose(); + } throw new Exception("Caught exception processing byte arrays in SculptMap(): e: " + e); } @@ -129,6 +133,11 @@ namespace LibreMetaverse.PrimMesher width++; height++; } + + if (needsScaling) + { + bm.Dispose(); + } } public List> ToRows(bool mirror) @@ -167,7 +176,6 @@ namespace LibreMetaverse.PrimMesher var info = new SKImageInfo(destWidth, destHeight); var scaledImage = new SKBitmap(info); srcImage.ScalePixels(scaledImage.PeekPixels(), new SKSamplingOptions(SKFilterMode.Linear)); - srcImage.Dispose(); return scaledImage; } }