--- rpl/src/formateur_fichiers.c 2010/03/08 08:34:15 1.6 +++ rpl/src/formateur_fichiers.c 2010/09/23 15:27:35 1.17 @@ -1,6 +1,6 @@ /* ================================================================================ - RPL/2 (R) version 4.0.12 + RPL/2 (R) version 4.0.20 Copyright (C) 1989-2010 Dr. BERTRAND Joël This file is part of RPL/2. @@ -20,7 +20,7 @@ */ -#include "rpl.conv.h" +#include "rpl-conv.h" /* @@ -1176,16 +1176,37 @@ formateur_fichier(struct_processus *s_et return(NULL); } - chaine = (unsigned char *) malloc((strlen((unsigned char *) - ((*s_objet).objet)) + 1) * sizeof(unsigned char)); - - if (chaine == NULL) + if ((longueur_champ == -1) || (strlen((unsigned char *) + (*s_objet).objet) < longueur_champ)) { - (*s_etat_processus).erreur_systeme = d_es_allocation_memoire; - return(NULL); + chaine = (unsigned char *) malloc((strlen((unsigned char *) + ((*s_objet).objet)) + 1) * sizeof(unsigned char)); + + if (chaine == NULL) + { + (*s_etat_processus).erreur_systeme = + d_es_allocation_memoire; + return(NULL); + } + + strcpy(chaine, (unsigned char *) ((*s_objet).objet)); } + else + { + chaine = (unsigned char *) malloc((longueur_champ + 1) + * sizeof(unsigned char)); + + if (chaine == NULL) + { + (*s_etat_processus).erreur_systeme = + d_es_allocation_memoire; + return(NULL); + } - strcpy(chaine, (unsigned char *) ((*s_objet).objet)); + strncpy(chaine, (unsigned char *) ((*s_objet).objet), + longueur_champ); + chaine[longueur_champ] = d_code_fin_chaine; + } } else if ((*s_objet).type == CPL) {