summaryrefslogtreecommitdiff
path: root/gi
diff options
context:
space:
mode:
authorRui Matos <tiagomatos@gmail.com>2015-05-21 17:53:17 +0200
committerRui Matos <tiagomatos@gmail.com>2015-07-17 15:17:09 +0200
commit8aa3d5935b4541be6e76e8792e58bb301fa4f7d1 (patch)
tree89c22c1b123e0cd5169c745840bd2a49d3e1812c /gi
parent5af6c722e5b7db90a3ca0832c46efe0c9142a0d1 (diff)
downloadpygobject-8aa3d5935b4541be6e76e8792e58bb301fa4f7d1.tar.gz
Avoid a silent long to int truncation
If the python object contains a value bigger than MAXUINT we'd silently truncate it when assigning to 'val' and the if condition would always be true. This was caught by a coverity scan. https://bugzilla.gnome.org/show_bug.cgi?id=749698
Diffstat (limited to 'gi')
-rw-r--r--gi/pygi-value.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/gi/pygi-value.c b/gi/pygi-value.c
index 9d5d0caf..7fdf7675 100644
--- a/gi/pygi-value.c
+++ b/gi/pygi-value.c
@@ -382,7 +382,7 @@ pyg_value_from_pyobject_with_error(GValue *value, PyObject *obj)
case G_TYPE_UINT:
{
if (PYGLIB_PyLong_Check(obj)) {
- guint val;
+ gulong val;
/* check that number is not negative */
if (PyLong_AsLongLong(obj) < 0)
@@ -390,7 +390,7 @@ pyg_value_from_pyobject_with_error(GValue *value, PyObject *obj)
val = PyLong_AsUnsignedLong(obj);
if (val <= G_MAXUINT)
- g_value_set_uint(value, val);
+ g_value_set_uint(value, (guint) val);
else
return -1;
} else {