From 992897c4ff2fb27a8c82d25b9a711e5308188960 Mon Sep 17 00:00:00 2001 From: Victor Fernandes Date: Mon, 10 Apr 2017 11:36:19 -0400 Subject: [PATCH] Avoid memory overrun --- stable.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/stable.c b/stable.c index c1f48fa..872329a 100644 --- a/stable.c +++ b/stable.c @@ -88,9 +88,10 @@ int st_install(STD s_table, char *lexeme, char type, int line){ } if (flag == 1){ bd_offset = 0; - for (j = 0; j <= s_table.st_offset; ++i){ + for (j = 0; j <= s_table.st_offset; ++j){ s_table.pstvr[j].plex = b_setmark(s_table.plsBD, bd_offset + s_table.pstvr[j].i_value.str_offset); - bd_offset += s_table.pstvr[j].i_value.str_offset + 1; /*Add one because the offset doesn't include '\0' */ + if (j < s_table.st_offset) + bd_offset += s_table.pstvr[j+1].i_value.str_offset + 1; /*Add one because the offset doesn't include '\0' */ } }