[pygobject/pygobject-3-4] Fix marshalling of ssize_t to smaller ints



commit 69a903f010a7f99af5f91730ebb106e281b6dd1d
Author: Martin Pitt <martinpitt gnome org>
Date:   Fri Nov 9 15:23:37 2012 +0100

    Fix marshalling of ssize_t to smaller ints
    
    Cherry-picked from trunk commit fa568949c46. Do not cherry-pick the test case
    udpate as those tests do not yet exist in the 3-4 branch.

 gi/pygi-marshal-from-py.c |   30 +++++++++++++++++++++++++++++-
 1 files changed, 29 insertions(+), 1 deletions(-)
---
diff --git a/gi/pygi-marshal-from-py.c b/gi/pygi-marshal-from-py.c
index b4c9fa0..d0e96db 100644
--- a/gi/pygi-marshal-from-py.c
+++ b/gi/pygi-marshal-from-py.c
@@ -40,11 +40,39 @@ gi_argument_from_py_ssize_t (GIArgument   *arg_out,
     switch (type_tag) {
     case GI_TYPE_TAG_VOID:
     case GI_TYPE_TAG_BOOLEAN:
+        goto unhandled_type;
+
     case GI_TYPE_TAG_INT8:
+        if (size_in >= G_MININT8 && size_in <= G_MAXINT8) {
+            arg_out->v_int8 = size_in;
+            return TRUE;
+        } else {
+            goto overflow;
+        }
+
     case GI_TYPE_TAG_UINT8:
+        if (size_in >= 0 && size_in <= G_MAXUINT8) {
+            arg_out->v_uint8 = size_in;
+            return TRUE;
+        } else {
+            goto overflow;
+        }
+
     case GI_TYPE_TAG_INT16:
+        if (size_in >= G_MININT16 && size_in <= G_MAXINT16) {
+            arg_out->v_int16 = size_in;
+            return TRUE;
+        } else {
+            goto overflow;
+        }
+
     case GI_TYPE_TAG_UINT16:
-        goto unhandled_type;
+        if (size_in >= 0 && size_in <= G_MAXUINT16) {
+            arg_out->v_uint16 = size_in;
+            return TRUE;
+        } else {
+            goto overflow;
+        }
 
         /* Ranges assume two's complement */
     case GI_TYPE_TAG_INT32:



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]