--- rpl/src/formateur_fichiers.c 2010/03/08 08:34:15 1.6 +++ rpl/src/formateur_fichiers.c 2010/03/09 09:19:49 1.7 @@ -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) {