Skip to content

Commit

Permalink
Free the buffer after use.
Browse files Browse the repository at this point in the history
  • Loading branch information
foollbar committed Jan 16, 2015
1 parent 2bce4e5 commit b24b0d4
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/6model/reprs/P6bigint.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,17 @@
static MVMuint64 mp_get_int64(mp_int * a) {
int i;
MVMuint64 res;

if (a->used == 0) {
return 0;
}

/* get number of digits of the lsb we have to read */
i = MIN(a->used,(int)((sizeof(MVMuint64)*CHAR_BIT+DIGIT_BIT-1)/DIGIT_BIT))-1;

/* get most significant digit of result */
res = DIGIT(a,i);

while (--i >= 0) {
res = (res << DIGIT_BIT) | DIGIT(a,i);
}
Expand Down Expand Up @@ -161,6 +161,7 @@ static void serialize(MVMThreadContext *tc, MVMSTable *st, void *data, MVMSerial
/* write the "is small" flag */
MVM_serialization_write_varint(tc, writer, 0);
MVM_serialization_write_str(tc, writer, str);
MVM_free(str);
MVM_free(buf);
}
else {
Expand Down Expand Up @@ -196,6 +197,7 @@ static void deserialize(MVMThreadContext *tc, MVMSTable *st, MVMObject *root, vo
body->u.bigint = MVM_malloc(sizeof(mp_int));
mp_init(body->u.bigint);
mp_read_radix(body->u.bigint, buf, 10);
MVM_free(buf);
}
}

Expand Down

0 comments on commit b24b0d4

Please sign in to comment.