From d684b3ae1150ff204f2052b994d9b1426e85b4b6 Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Thu, 22 Nov 2012 10:35:03 +0100 Subject: [PATCH] fixed getString function in NIF loader --- components/nif/nif_file.hpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/components/nif/nif_file.hpp b/components/nif/nif_file.hpp index a4eaa8990..23bccb0fe 100644 --- a/components/nif/nif_file.hpp +++ b/components/nif/nif_file.hpp @@ -193,11 +193,12 @@ public: std::string getString(size_t length) { - std::string str; - str.resize(length); + std::vector str (length+1, 0); + if(inp->read(&str[0], length) != length) - return std::string(); - return str.substr(0, str.find('\0')); + throw std::runtime_error ("string length in NIF file does not match"); + + return &str[0]; } std::string getString() {