From 4220e42d15b97675763d1812ebe6b54229e14373 Mon Sep 17 00:00:00 2001 From: Xawirses Date: Fri, 1 Apr 2016 10:59:35 +0200 Subject: [PATCH] Repare Bugs --- src/analyseur_syntaxyque.c | 24 ++++++++++++------------ src/parcours.c | 2 +- src/util.c | 2 +- 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/analyseur_syntaxyque.c b/src/analyseur_syntaxyque.c index 81a623e..ab69bc8 100644 --- a/src/analyseur_syntaxyque.c +++ b/src/analyseur_syntaxyque.c @@ -46,7 +46,7 @@ n_prog *programme() { n_l_dec *herite_var = NULL; n_l_dec *herite_func = NULL; - n_prog *sreturn; + n_prog *sreturn = NULL; if( !est_premier( _optDecVariables_, uniteCourante ) && !est_premier( _listeDecFonctions_, uniteCourante ) @@ -207,7 +207,7 @@ n_dec * declarationFonction() { n_l_dec *param = NULL; n_l_dec *variables = NULL; n_instr *corps = NULL; - n_dec *sreturn; + n_dec *sreturn = NULL; if( uniteCourante == ID_FCT ) { name = duplique_chaine(yytext); elementConsome(); @@ -371,7 +371,7 @@ n_l_instr *listeInstructions() { n_instr *instructionSi() { openSection( __func__ ); - n_instr *sreturn; + n_instr *sreturn = NULL; n_exp *test = NULL; n_instr *alors = NULL; n_instr *sinon = NULL; @@ -401,7 +401,7 @@ n_instr *instructionSi() { n_instr *optSinon() { openSection( __func__ ); - n_instr *sreturn; + n_instr *sreturn = NULL; if( uniteCourante == SINON ) { elementConsome(); uniteCourante = yylex(); @@ -417,9 +417,9 @@ n_instr *optSinon() { n_instr *instructionTantque() { openSection( __func__ ); - n_instr *sreturn; - n_exp *test; - n_instr *faire; + n_instr *sreturn = NULL; + n_exp *test = NULL; + n_instr *faire = NULL; if( uniteCourante == TANTQUE ) { elementConsome(); @@ -446,8 +446,8 @@ n_instr *instructionTantque() { n_instr *instructionAppel() { openSection( __func__ ); - n_instr *sreturn; - n_appel *app; + n_instr *sreturn = NULL; + n_appel *app = NULL; if( est_premier( _instructionAppel_, uniteCourante ) ) { app = appelFct(); @@ -468,8 +468,8 @@ n_instr *instructionAppel() { n_instr *instructionRetour() { openSection( __func__ ); - n_instr *sreturn; - n_exp *expr; + n_instr *sreturn = NULL; + n_exp *expr = NULL; if( uniteCourante == RETOUR ) { elementConsome(); @@ -623,7 +623,7 @@ n_exp *expressionBis(n_exp *herite) { } n_exp *conjonction() { - n_exp *sreturn; + n_exp *sreturn = NULL; n_exp *herite_neg = NULL; openSection( __func__ ); diff --git a/src/parcours.c b/src/parcours.c index ab61457..ffd502c 100644 --- a/src/parcours.c +++ b/src/parcours.c @@ -133,7 +133,7 @@ void parcours_instr_si(n_instr *n) sprintf(tmp,"%s:",faux); printMips(tmp); - if(n->u.si_.sinon){ + if(n->u.si_.sinon) { parcours_instr(n->u.si_.sinon); } diff --git a/src/util.c b/src/util.c index d183348..900d05f 100644 --- a/src/util.c +++ b/src/util.c @@ -28,7 +28,7 @@ void erreur_1s(char *message, char *s) { /*-------------------------------------------------------------------------*/ char *duplique_chaine(char *src) { - char *dest = malloc(sizeof(char) * strlen(src)); + char *dest = malloc(sizeof(char) * (strlen(src) + 1)); strcpy(dest, src); return dest; }