From 22320ec58e22f389d383dff53dbf0a2996fba27d Mon Sep 17 00:00:00 2001 From: Amorilia <amorilia@users.sourceforge.net> Date: Wed, 15 Mar 2006 17:02:15 +0000 Subject: [PATCH] Fix in NiStringPalette when string has zero length. --- NIF_Blocks.cpp | 2 +- NIF_IO.cpp | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/NIF_Blocks.cpp b/NIF_Blocks.cpp index 5c07d6ae..e22c68a1 100644 --- a/NIF_Blocks.cpp +++ b/NIF_Blocks.cpp @@ -4466,7 +4466,7 @@ string NiStringPalette::asString() const { out << "String Palette:" << endl << " 0: "; - for ( uint i = 0; i < pal.size() - 1; ++i ) { + if ( pal.size() > 0 ) for ( uint i = 0; i < pal.size() - 1; ++i ) { if ( pal[i] == '\0') { out << endl << " " << i + 1 << ": "; } else { diff --git a/NIF_IO.cpp b/NIF_IO.cpp index 32580461..1ec9fcbe 100644 --- a/NIF_IO.cpp +++ b/NIF_IO.cpp @@ -231,8 +231,10 @@ void ReadFVector4( fVector4& fvec, istream& in ){ string ReadString( istream &in ) { uint len = ReadUInt( in ); string out; - out.resize( len ); - in.read( (char*)&out[0], len ); + if ( len > 0 ) { + out.resize( len ); + in.read( (char*)&out[0], len ); + } return out; } -- GitLab