diff --git a/trunk/src/ctemplate/str_ref.h.in b/trunk/src/ctemplate/str_ref.h.in index e6dd13e..599c84b 100644 --- a/trunk/src/ctemplate/str_ref.h.in +++ b/trunk/src/ctemplate/str_ref.h.in @@ -51,7 +51,10 @@ public: template str_ref_basic(const U& c) { - assign(&*c.begin(), c.end() - c.begin() + &*c.begin()); + if (c.end() != c.begin()) + assign(&*c.begin(), c.end() - c.begin() + &*c.begin()); + else + clear(); } str_ref_basic(const void* b, const void* e) @@ -66,7 +69,10 @@ public: str_ref_basic(const char* b) { - assign(b, strlen(b)); + if (b) + assign(b, strlen(b)); + else + clear(); } void clear() diff --git a/trunk/src/windows/ctemplate/str_ref.h b/trunk/src/windows/ctemplate/str_ref.h index ff63c23..20a2663 100644 --- a/trunk/src/windows/ctemplate/str_ref.h +++ b/trunk/src/windows/ctemplate/str_ref.h @@ -56,7 +56,10 @@ public: template str_ref_basic(const U& c) { - assign(&*c.begin(), c.end() - c.begin() + &*c.begin()); + if (c.end() != c.begin()) + assign(&*c.begin(), c.end() - c.begin() + &*c.begin()); + else + clear(); } str_ref_basic(const void* b, const void* e) @@ -71,7 +74,10 @@ public: str_ref_basic(const char* b) { - assign(b, strlen(b)); + if (b) + assign(b, strlen(b)); + else + clear(); } void clear()