Running Valgrind memcheck tool on chat.c while communicating with a
modem found additional memory leaks. These fixes plumb those.
Signed-off-by: Robert Bartel <r.bartel@gmx.net>
Signed-off-by: Paul Mackerras <paulus@ozlabs.org>
char temp[STR_LEN];
int c, printed = 0, len, minlen;
register char *s = temp, *end = s + STR_LEN;
char temp[STR_LEN];
int c, printed = 0, len, minlen;
register char *s = temp, *end = s + STR_LEN;
+ char *s1, *logged = temp;
- string = clean(string, 0);
+ string = s1 = clean(string, 0);
len = strlen(string);
minlen = (len > sizeof(fail_buffer)? len: sizeof(fail_buffer)) - 1;
len = strlen(string);
minlen = (len > sizeof(fail_buffer)? len: sizeof(fail_buffer)) - 1;
if (len > STR_LEN) {
msgf("expect string is too long");
exit_code = 1;
if (len > STR_LEN) {
msgf("expect string is too long");
exit_code = 1;
return 0;
}
if (len == 0) {
if (verbose)
msgf("got it");
return 0;
}
if (len == 0) {
if (verbose)
msgf("got it");
strftime (report_buffer, 20, "%b %d %H:%M:%S ", tm_now);
strcat (report_buffer, report_string[n]);
strftime (report_buffer, 20, "%b %d %H:%M:%S ", tm_now);
strcat (report_buffer, report_string[n]);
+ free(report_string[n]);
report_string[n] = (char *) NULL;
report_gathering = 1;
break;
report_string[n] = (char *) NULL;
report_gathering = 1;
break;
alarmed = 0;
exit_code = n + 4;
strcpy(fail_reason = fail_buffer, abort_string[n]);
alarmed = 0;
exit_code = n + 4;
strcpy(fail_reason = fail_buffer, abort_string[n]);
exit_code = 3;
alarmed = 0;
exit_code = 3;
alarmed = 0;