X-Git-Url: http://git.marmaro.de/?p=mmh;a=blobdiff_plain;f=sbr%2Fm_getfld2.c;fp=sbr%2Fm_getfld2.c;h=18ad81283d015f00092fd23df55d43851a94bf40;hp=74d25e4e9e03ec3f699a4f2c8ab5d44a23a8d745;hb=cdb32d069bdcb6fa04ca7e3d87240442665611b0;hpb=02ad941fcb6ccc24fab97dff24a8f5253ab7e538 diff --git a/sbr/m_getfld2.c b/sbr/m_getfld2.c index 74d25e4..18ad812 100644 --- a/sbr/m_getfld2.c +++ b/sbr/m_getfld2.c @@ -26,8 +26,6 @@ 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 @@ -57,7 +55,7 @@ m_getfld2(enum state s, struct field *f, FILE *msg) nchars = getline(&tmpline, &len, msg); if (nchars < 1) { free(f->value); - *f = free_field; + *f = (struct field) { "\0", 0, NULL, 0, 0 }; if (feof(msg)) { return FILEEOF2; } else { @@ -132,12 +130,15 @@ m_getfld2(enum state s, struct field *f, FILE *msg) return ret; case BODY2: - free(f->value); - *f = free_field; + *f->name = '\0'; + f->namelen = 0; nchars = getline(&tmpline, &len, msg); if (nchars < 1) { - free(tmpline); + free(f->value); + f->value = NULL; + f->valuelen = 0; + f->alloclen = 0; if (feof(msg)) { return FILEEOF2; } else { @@ -149,6 +150,7 @@ m_getfld2(enum state s, struct field *f, FILE *msg) ret = LENERR2; } + free(f->value); f->value = tmpline; f->valuelen = nchars; f->alloclen = len;