[glibmm] Correct some range checks to use >= instead of just >.
- From: Murray Cumming <murrayc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glibmm] Correct some range checks to use >= instead of just >.
- Date: Mon, 21 Mar 2011 11:44:42 +0000 (UTC)
commit 7d9352ab34a30950d81b1e1148d6f5a6401a74c9
Author: Murray Cumming <murrayc murrayc com>
Date: Mon Mar 21 12:44:36 2011 +0100
Correct some range checks to use >= instead of just >.
* glib/glibmm/stringutils.cc: Glib::Ascii::strtod():
* glib/src/variant.[hg|ccg]: get(): Correct the range check. This would
previously not have caught all wrong ranges.
Thanks to Michael Edwards.
ChangeLog | 9 +++++++++
glib/glibmm/stringutils.cc | 2 +-
glib/src/variant.ccg | 6 +++---
glib/src/variant.hg | 2 +-
4 files changed, 14 insertions(+), 5 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 9a01274..e01de47 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2011-03-21 Murray Cumming <murrayc murrayc com>
+
+ Correct some range checks to use >= instead of just >.
+
+ * glib/glibmm/stringutils.cc: Glib::Ascii::strtod():
+ * glib/src/variant.[hg|ccg]: get(): Correct the range check. This would
+ previously not have caught all wrong ranges.
+ Thanks to Michael Edwards.
+
2011-03-20 Krzesimir Nowak <qdlacz gmail com>
Vectorutils, ArrayHandle: Check for NULL pointers.
diff --git a/glib/glibmm/stringutils.cc b/glib/glibmm/stringutils.cc
index 1d78667..5b61dd1 100644
--- a/glib/glibmm/stringutils.cc
+++ b/glib/glibmm/stringutils.cc
@@ -45,7 +45,7 @@ double Glib::Ascii::strtod(const std::string& str,
std::string::size_type& end_index,
std::string::size_type start_index)
{
- if(start_index > str.size())
+ if(start_index >= str.size())
{
throw std::out_of_range("out of range (strtod): start_index > str.size()");
}
diff --git a/glib/src/variant.ccg b/glib/src/variant.ccg
index d47ae6c..df93dcb 100644
--- a/glib/src/variant.ccg
+++ b/glib/src/variant.ccg
@@ -82,7 +82,7 @@ VariantContainerBase::create_tuple(const std::vector<VariantBase>& children)
void VariantContainerBase::get(VariantBase& child, gsize index) const
{
- if(index > g_variant_n_children(gobject_))
+ if(index >= g_variant_n_children(gobject_))
throw std::out_of_range(
"VariantContainerBase::get(): Index out of bounds.");
@@ -248,7 +248,7 @@ Glib::ustring Variant<type_vec_ustring>::get(gsize index) const
const gchar** array = g_variant_get_strv(const_cast<GVariant*>(gobj()),
&n_elements);
- if(index > n_elements)
+ if(index >= n_elements)
throw std::out_of_range(
"Variant< std::vector<Glib::ustring> >::get(): Index out of bounds.");
@@ -332,7 +332,7 @@ std::string Variant<type_vec_string>::get(gsize index) const
const gchar** array =
g_variant_get_bytestring_array(const_cast<GVariant*>(gobj()), &n_elements);
- if(index > n_elements)
+ if(index >= n_elements)
throw std::out_of_range(
"Variant< std::vector<std::string> >::get(): Index out of bounds.");
diff --git a/glib/src/variant.hg b/glib/src/variant.hg
index 2a10aff..235205a 100644
--- a/glib/src/variant.hg
+++ b/glib/src/variant.hg
@@ -912,7 +912,7 @@ T Variant< std::vector<T> >::get(gsize index) const
g_variant_get_fixed_array(const_cast<GVariant*>(gobj()), &n_elements,
sizeof(T)));
- if(index > n_elements)
+ if(index >= n_elements)
throw std::out_of_range(
"Variant< std::vector<T> >::get(): Index out of bounds.");
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]