summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/store.cc
diff options
context:
space:
mode:
authorzelgadis <zelgadis@c06c8d41-db1a-0410-9941-cceddc491573>2009-01-31 16:26:27 +0000
committerzelgadis <zelgadis@c06c8d41-db1a-0410-9941-cceddc491573>2009-01-31 16:26:27 +0000
commit8214e2be4bb79403f7fa585b83a8b015a1d0b0d8 (patch)
tree5595ca4bb0590012690820a217692d3c38e54259 /crawl-ref/source/store.cc
parentcbceff8b6a6ec323331c01f10fe098db9a002111 (diff)
downloadcrawl-ref-8214e2be4bb79403f7fa585b83a8b015a1d0b0d8.tar.gz
crawl-ref-8214e2be4bb79403f7fa585b83a8b015a1d0b0d8.zip
Fix bug #2551376: CrawlStoreValue conversion constructors were crashing.
git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@8863 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref/source/store.cc')
-rw-r--r--crawl-ref/source/store.cc32
1 files changed, 21 insertions, 11 deletions
diff --git a/crawl-ref/source/store.cc b/crawl-ref/source/store.cc
index f4393ab025..f9b4216623 100644
--- a/crawl-ref/source/store.cc
+++ b/crawl-ref/source/store.cc
@@ -25,6 +25,8 @@ CrawlStoreValue::CrawlStoreValue(const CrawlStoreValue &other)
{
ASSERT(other.type >= SV_NONE && other.type < NUM_STORE_VAL_TYPES);
+ val.ptr = NULL;
+
type = other.type;
flags = other.flags;
@@ -105,68 +107,74 @@ CrawlStoreValue::CrawlStoreValue(const store_flags _flags,
// Conversion constructors
CrawlStoreValue::CrawlStoreValue(const bool _val)
- : type(SV_BOOL), flags(0)
+ : type(SV_BOOL), flags(SFLAG_UNSET)
{
get_bool() = _val;
}
CrawlStoreValue::CrawlStoreValue(const char &_val)
- : type(SV_BYTE), flags(0)
+ : type(SV_BYTE), flags(SFLAG_UNSET)
{
get_byte() = _val;
}
CrawlStoreValue::CrawlStoreValue(const short &_val)
- : type(SV_SHORT), flags(0)
+ : type(SV_SHORT), flags(SFLAG_UNSET)
{
get_short() = _val;
}
CrawlStoreValue::CrawlStoreValue(const long &_val)
- : type(SV_LONG), flags(0)
+ : type(SV_LONG), flags(SFLAG_UNSET)
{
get_long() = _val;
}
CrawlStoreValue::CrawlStoreValue(const float &_val)
- : type(SV_FLOAT), flags(0)
+ : type(SV_FLOAT), flags(SFLAG_UNSET)
{
get_float() = _val;
}
CrawlStoreValue::CrawlStoreValue(const std::string &_val)
- : type(SV_STR), flags(0)
+ : type(SV_STR), flags(SFLAG_UNSET)
{
+ val.ptr = NULL;
get_string() = _val;
}
CrawlStoreValue::CrawlStoreValue(const char* _val)
- : type(SV_STR), flags(0)
+ : type(SV_STR), flags(SFLAG_UNSET)
{
+ val.ptr = NULL;
get_string() = _val;
}
CrawlStoreValue::CrawlStoreValue(const coord_def &_val)
- : type(SV_COORD), flags(0)
+ : type(SV_COORD), flags(SFLAG_UNSET)
{
+ val.ptr = NULL;
get_coord() = _val;
}
CrawlStoreValue::CrawlStoreValue(const item_def &_val)
- : type(SV_ITEM), flags(0)
+ : type(SV_ITEM), flags(SFLAG_UNSET)
{
+ val.ptr = NULL;
get_item() = _val;
}
CrawlStoreValue::CrawlStoreValue(const CrawlHashTable &_val)
- : type(SV_HASH), flags(0)
+ : type(SV_HASH), flags(SFLAG_UNSET)
{
+ val.ptr = NULL;
get_table() = _val;
}
CrawlStoreValue::CrawlStoreValue(const CrawlVector &_val)
- : type(SV_VEC), flags(0)
+ : type(SV_VEC), flags(SFLAG_UNSET)
{
+ val.ptr = NULL;
get_vector() = _val;
}
@@ -626,6 +634,8 @@ CrawlVector &CrawlStoreValue::new_vector(store_val_type _type,
type = (x); \
} \
} \
+ else \
+ delete (value); \
flags &= ~SFLAG_UNSET; \
return *((_type) val.ptr);