X-Git-Url: http://git.marmaro.de/?p=mmh;a=blobdiff_plain;f=sbr%2Fm_getfld2.c;h=6545d0f7539632b54a6f50d92b43f151b4c12d71;hp=cd1c6bea09186849db1942434c796ffe0b99ec33;hb=a87df3543d3bc128ba4079d1f95638476ba5ca50;hpb=bf1c715de0935bc1a472925fcf80be70b30d2724 diff --git a/sbr/m_getfld2.c b/sbr/m_getfld2.c index cd1c6be..6545d0f 100644 --- a/sbr/m_getfld2.c +++ b/sbr/m_getfld2.c @@ -26,6 +26,8 @@ static enum threestate is_falted(FILE *); static size_t copyname(char *, char *); static bool is_separator(char *); +struct field free_field = { "\0", 0, NULL, 0, 0 }; + /* ** FLD2: We read a (complete) header field @@ -55,7 +57,7 @@ m_getfld2(enum state s, struct field *f, FILE *msg) nchars = getline(&tmpline, &len, msg); if (nchars < 1) { free(f->value); - *f = (struct field) { "\0", 0, NULL, 0, 0 }; + *f = free_field; if (feof(msg)) { return FILEEOF2; } else { @@ -130,15 +132,12 @@ m_getfld2(enum state s, struct field *f, FILE *msg) return ret; case BODY2: - *f->name = '\0'; - f->namelen = 0; + free(f->value); + *f = free_field; nchars = getline(&tmpline, &len, msg); if (nchars < 1) { - free(f->value); - f->value = NULL; - f->valuelen = 0; - f->alloclen = 0; + free(tmpline); if (feof(msg)) { return FILEEOF2; } else { @@ -150,7 +149,6 @@ m_getfld2(enum state s, struct field *f, FILE *msg) ret = LENERR2; } - free(f->value); f->value = tmpline; f->valuelen = nchars; f->alloclen = len;