Merge pull request #83 from tofurky/unterminated_string_calloc

Avoid printing unterminated string in readline()
This commit is contained in:
Mark Janssen 2024-09-16 12:53:42 +02:00 committed by GitHub
commit 8b2661ecd7
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

2
io.c
View file

@ -57,7 +57,7 @@ int readline(PTSTREAM *pts) {
if( args_info.verbose_flag ) {
/* Copy line of data into dstr without trailing newline */
char *dstr = malloc(strlen(buf) + 1);
char *dstr = calloc(1, strlen(buf) + 1);
strncpy( dstr, buf, strlen(buf));
if (strcmp(dstr, ""))
message( " <- %s\n", dstr );