From 8f08effe93bab7980e1cb83cebe1dba8cc3abb46 Mon Sep 17 00:00:00 2001 From: ArseniyShestakov Date: Fri, 6 Feb 2015 10:51:32 +0300 Subject: [PATCH] Check that resource type set before setName used --- lib/filesystem/ResourceID.cpp | 5 +++++ lib/filesystem/ResourceID.h | 3 ++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/filesystem/ResourceID.cpp b/lib/filesystem/ResourceID.cpp index 323f1bc14..79e5498b2 100644 --- a/lib/filesystem/ResourceID.cpp +++ b/lib/filesystem/ResourceID.cpp @@ -33,6 +33,7 @@ ResourceID::ResourceID() } ResourceID::ResourceID(std::string name) + :type(EResType::UNDEFINED) { CFileInfo info(std::move(name)); setType(info.getType()); @@ -40,6 +41,7 @@ ResourceID::ResourceID(std::string name) } ResourceID::ResourceID(std::string name, EResType::Type type) + :type(EResType::UNDEFINED) { setType(type); setName(std::move(name)); @@ -57,6 +59,9 @@ EResType::Type ResourceID::getType() const void ResourceID::setName(std::string name) { + // setName shouldn't be used if type is UNDEFINED + assert(type != EResType::UNDEFINED); + this->name = std::move(name); size_t dotPos = this->name.find_last_of("/."); diff --git a/lib/filesystem/ResourceID.h b/lib/filesystem/ResourceID.h index 33ed09580..8b1c31798 100644 --- a/lib/filesystem/ResourceID.h +++ b/lib/filesystem/ResourceID.h @@ -56,7 +56,8 @@ namespace EResType ERM, ERT, ERS, - OTHER + OTHER, + UNDEFINED }; }