m_getfld_state_t s = *gstate;
if (s) {
- if (s->fdelim) free (s->fdelim-1);
+ if (s->fdelim) {
+ free (s->fdelim-1);
+ free (s->pat_map);
+ }
free (s);
*gstate = 0;
}
size_t num_read;
if (retain < s->end - s->readpos) retain = s->end - s->readpos;
- /* assert (retain <= s->readpos - s->msg_buf <= sizeof msg_buf); */
+ assert (retain <= s->readpos - s->msg_buf);
/* Move what we want to retain at end of the buffer to the beginning. */
memmove (s->msg_buf, s->readpos - retain, retain);
if (c != EOF) c = Peek (s);
if (max < n) {
- /* the dest buffer is full */
+ /* The dest buffer is full. Need to back the read
+ pointer up by one because when m_getfld() is
+ reentered, it will read a character. Then
+ we'll jump right to the FLDPLUS handling code,
+ which will not store that character, but
+ instead move on to the next one. */
+ if (s->readpos > s->msg_buf) {
+ --s->readpos;
+ --s->bytes_read;
+ }
s->state = FLDPLUS;
finished = 1;
} else if (c != ' ' && c != '\t') {
} else {
/* not a Unix style maildrop */
s->readpos -= s->bytes_read;
+ s->bytes_read = 0;
delimstr = mmdlm2;
s->msg_style = MS_MMDF;
}
Note that on input, a character had already been read
with Getc(). It will be unget by m_getfld () on return. */
s->readpos -= s->bytes_read - 1;
+ s->bytes_read = 1;
return 0;
}