diff options
author | tony@chromium.org <tony@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-06-01 16:54:16 +0000 |
---|---|---|
committer | tony@chromium.org <tony@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-06-01 16:54:16 +0000 |
commit | a5b7173002665650d9c0478cbe1a157fed31f7f5 (patch) | |
tree | 027a4754d1183996d58dde39c7efa4d96099dbbc /ui | |
parent | 68f3bd2b87562501086c8040dc020a9d1cc8c5af (diff) | |
download | chromium_src-a5b7173002665650d9c0478cbe1a157fed31f7f5.zip chromium_src-a5b7173002665650d9c0478cbe1a157fed31f7f5.tar.gz chromium_src-a5b7173002665650d9c0478cbe1a157fed31f7f5.tar.bz2 |
Read int properties from the X server as long.
The documentation says that the values are returned as long,
even though the range of values is only 32-bit. This makes
it safe to cast from 64-bit to 32-bit.
GetIntProperty isn't used anywhere and GetIntArrayProperty is
only used on ChromiumOS, so it never hit this bug before.
Review URL: http://codereview.chromium.org/7020010
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@87489 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui')
-rw-r--r-- | ui/base/x/x11_util.cc | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/ui/base/x/x11_util.cc b/ui/base/x/x11_util.cc index 3cc80d6..ee443ac 100644 --- a/ui/base/x/x11_util.cc +++ b/ui/base/x/x11_util.cc @@ -242,7 +242,7 @@ bool GetWindowRect(XID window, gfx::Rect* rect) { bool PropertyExists(XID window, const std::string& property_name) { Atom type = None; int format = 0; // size in bits of each item in 'property' - long unsigned int num_items = 0; + unsigned long num_items = 0; unsigned char* property = NULL; int result = GetProperty(window, property_name, 1, @@ -257,7 +257,7 @@ bool PropertyExists(XID window, const std::string& property_name) { bool GetIntProperty(XID window, const std::string& property_name, int* value) { Atom type = None; int format = 0; // size in bits of each item in 'property' - long unsigned int num_items = 0; + unsigned long num_items = 0; unsigned char* property = NULL; int result = GetProperty(window, property_name, 1, @@ -270,7 +270,7 @@ bool GetIntProperty(XID window, const std::string& property_name, int* value) { return false; } - *value = *(reinterpret_cast<int*>(property)); + *value = static_cast<int>(*(reinterpret_cast<long*>(property))); XFree(property); return true; } @@ -280,7 +280,7 @@ bool GetIntArrayProperty(XID window, std::vector<int>* value) { Atom type = None; int format = 0; // size in bits of each item in 'property' - long unsigned int num_items = 0; + unsigned long num_items = 0; unsigned char* properties = NULL; int result = GetProperty(window, property_name, @@ -294,9 +294,11 @@ bool GetIntArrayProperty(XID window, return false; } - int* int_properties = reinterpret_cast<int*>(properties); + long* int_properties = reinterpret_cast<long*>(properties); value->clear(); - value->insert(value->begin(), int_properties, int_properties + num_items); + for (unsigned long i = 0; i < num_items; ++i) { + value->push_back(static_cast<int>(int_properties[i])); + } XFree(properties); return true; } @@ -306,7 +308,7 @@ bool GetAtomArrayProperty(XID window, std::vector<Atom>* value) { Atom type = None; int format = 0; // size in bits of each item in 'property' - long unsigned int num_items = 0; + unsigned long num_items = 0; unsigned char* properties = NULL; int result = GetProperty(window, property_name, @@ -331,7 +333,7 @@ bool GetStringProperty( XID window, const std::string& property_name, std::string* value) { Atom type = None; int format = 0; // size in bits of each item in 'property' - long unsigned int num_items = 0; + unsigned long num_items = 0; unsigned char* property = NULL; int result = GetProperty(window, property_name, 1024, |