[gcr] asn1x: Fix assertion in loading of default integer



commit 7f18d97354042cc6f95ebba0a4a4089ab891e066
Author: Stef Walter <stefw gnome org>
Date:   Wed Aug 1 11:15:07 2012 +0200

    asn1x: Fix assertion in loading of default integer

 egg/egg-asn1x.c |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)
---
diff --git a/egg/egg-asn1x.c b/egg/egg-asn1x.c
index 1717127..5168e3f 100644
--- a/egg/egg-asn1x.c
+++ b/egg/egg-asn1x.c
@@ -2167,6 +2167,7 @@ anode_write_integer_ulong (gulong value,
 	gint bytes, i, off;
 	guchar *at;
 	gboolean sign;
+	gsize len;
 
 	for (i = 0; i < sizeof (gulong); ++i) {
 		off = sizeof (gulong) - (i + 1);
@@ -2184,9 +2185,10 @@ anode_write_integer_ulong (gulong value,
 	/* If the first byte would make this negative, then add a zero */
 	at = buf + (sizeof (gulong) - bytes);
 	sign = !!(at[0] & 0x80);
+	len = bytes + (sign ? 1 : 0);
 
 	if (data) {
-		g_assert (*n_data >= bytes + 1);
+		g_assert (*n_data >= len);
 		if (sign) {
 			data[0] = 0;
 			data++;
@@ -2194,7 +2196,7 @@ anode_write_integer_ulong (gulong value,
 		memcpy (data, at, bytes);
 	}
 
-	*n_data = bytes + (sign ? 1 : 0);
+	*n_data = len;
 }
 
 static GBytes *



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