fix #25, terminate the pasted string with NUL

Allocate one more byte, and append a '\0'.

Whoops.
This commit is contained in:
Brad Grantham 2018-07-20 20:21:57 -07:00
parent 72134f94dd
commit a9aefa583a

View File

@ -1126,8 +1126,9 @@ struct apple2screen : public widget
fseek(fp, 0, SEEK_END);
long length = ftell(fp);
fseek(fp, 0, SEEK_SET);
char *text = (char *)malloc(length);
char *text = (char *)malloc(length + 1);
fread(text, 1, length, fp);
text[length] = '\0';
event_queue.push_back({PASTE, 0, text});
fclose(fp);
return true;