{
gint punt, ris, last;
gint n_data;
+ guchar val;
g_assert (end >= at);
g_assert (cls != NULL);
} else {
punt = 1;
ris = 0;
- while (punt <= n_data && at[punt] & 128) {
- int last = ris;
- ris = ris * 128 + (at[punt++] & 0x7F);
+ while (punt <= n_data) {
+ val = at[punt++];
+ last = ris;
+ ris = ris * 128;
/* wrapper around, and no bignums... */
if (ris < last)
return FALSE;
- }
- if (punt >= n_data)
- return FALSE;
+ last = ris;
+ ris += (val & 0x7F);
+
+ /* wrapper around, and no bignums... */
+ if (ris < last)
+ return FALSE;
- last = ris;
- ris = ris * 128 + (at[punt++] & 0x7F);
+ if ((val & 0x7F) == val)
+ break;
+ }
- /* wrapper around, and no bignums... */
- if (ris < last)
+ if (punt >= n_data)
return FALSE;
*off = punt;
ans = 0;
while (punt <= k && punt < n_data) {
last = ans;
- ans = ans * 256 + at[punt++];
+ ans = ans * 256;
+
+ /* we wrapped around, no bignum support... */
+ if (ans < last)
+ return -2;
+
+ last = ans;
+ ans += at[punt++];
/* we wrapped around, no bignum support... */
if (ans < last)