Permalink
Browse files

Fix two subtle bugs in pmc_encode.

  • Loading branch information...
1 parent 17aeba9 commit b769bc3ab322619d5696385a9903e81fd1c15210 @atrodo committed Dec 14, 2010
Showing with 4 additions and 3 deletions.
  1. +2 −1 core.c
  2. +2 −2 pmc.c
View
3 core.c
@@ -418,8 +418,9 @@ core_exec(Lorito_Interp *interp)
{
INVALID_OP("store: cannot store to null pmc");
}
- if (offset+length >= $P(op->dest)->size)
+ if (offset+length > $P(op->dest)->size)
{
+ printf("%d >= %d\n", offset+length, $P(op->dest)->size);
INVALID_OP("store: outside range");
}
View
4 pmc.c
@@ -68,13 +68,13 @@ lorito_pmc_encode(Lorito_Interp *interp, Lorito_PMC *dest, int offset, Lorito_PM
{
return result;
}
- if (offset+length >= dest->size)
+ if (offset+length > dest->size)
{
return result;
}
// Reuse a slot if there is one, otherwise make one.
- int current = *(int *) (src->data + offset);
+ int current = *(int *) (dest->data + offset);
if ((current > 0) && (current <= dest->ptr_count))
{
// Even if the new PMC is null, we're going to keep using it.

0 comments on commit b769bc3

Please sign in to comment.