aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSérgio Medeiros <sqmedeiros@gmail.com>2020-08-26 15:58:26 -0300
committerGitHub <noreply@github.com>2020-08-26 15:58:26 -0300
commit3e5f92353fad743d0a752069a738894fe33576ec (patch)
tree2b1c85129c4dd65f35714a9c9d5ba3aae7fd06eb
parentb52deae33ab409e2829ad2a31bad0c126c9cb019 (diff)
parentc66cedbdccce431b9b9b42fb1a7aec81a8c64dfe (diff)
downloadlpeglabel-3e5f92353fad743d0a752069a738894fe33576ec.tar.gz
lpeglabel-3e5f92353fad743d0a752069a738894fe33576ec.tar.bz2
lpeglabel-3e5f92353fad743d0a752069a738894fe33576ec.zip
Merge pull request #28 from edubart/fix-buffer-overflow
Fix issue #27
-rw-r--r--lpcode.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/lpcode.c b/lpcode.c
index a2d08f7..78c6566 100644
--- a/lpcode.c
+++ b/lpcode.c
@@ -535,16 +535,18 @@ static int addoffsetinst (CompileState *compst, Opcode op) {
535 535
536/* labeled failure */ 536/* labeled failure */
537static void codethrow (CompileState *compst, TTree *throw) { 537static void codethrow (CompileState *compst, TTree *throw) {
538 int recov, aux; 538 int recov, aux, n;
539 if (throw->u.ps != 0) { 539 if (throw->u.ps != 0) {
540 recov = addoffsetinst(compst, IThrowRec); 540 recov = addoffsetinst(compst, IThrowRec);
541 assert(sib1(sib2(throw))->tag == TXInfo); 541 assert(sib1(sib2(throw))->tag == TXInfo);
542 n = sib1(sib2(throw))->u.n;
542 } else { 543 } else {
543 recov = addinstruction(compst, IThrow, 0); 544 recov = addinstruction(compst, IThrow, 0);
545 n = -1;
544 } 546 }
545 aux = nextinstruction(compst); 547 aux = nextinstruction(compst);
546 getinstr(compst, aux).i.key = throw->key; /* next instruction keeps only rule name */ 548 getinstr(compst, aux).i.key = throw->key; /* next instruction keeps only rule name */
547 getinstr(compst, recov).i.key = sib1(sib2(throw))->u.n; /* rule number */ 549 getinstr(compst, recov).i.key = n; /* rule number */
548} 550}
549/* labeled failure */ 551/* labeled failure */
550 552