- total_length = total_length + line_length + 1;
- msg = realloc(msg, total_length + 1);
- strcpy(msgend, buf);
- msgend[line_length++] = '\n' ;
- msgend[line_length] = 0;
- msgend = &msgend[line_length];
+ buffer_length = content_length + line_length + 2;
+ msg = realloc(msg, buffer_length);
+ if (msg == NULL) {
+ wprintf("<B>realloc() error! "
+ "couldn't get %d bytes: %s</B><BR><BR>\n",
+ buffer_length + 1,
+ strerror(errno));
+ return;
+ }
+ strcpy(&msg[content_length], buf);
+ content_length += line_length;
+ strcpy(&msg[content_length], "\n");
+ content_length += 1;