In get_string(), 0-terminate the contents of buf ``just in case'';

otherwise, if the very first fgetc() already yielded EOF, the returned
string won't get terminated at all.

MFC after:	1 day
This commit is contained in:
Joerg Wunsch 2001-08-28 21:27:36 +00:00
parent 7ae71655e7
commit 8a2ecea916

View File

@ -124,6 +124,7 @@ get_string(int procfd, void *offset, int max) {
err(1, "fdopen");
buf = malloc( size = (max ? max : 64 ) );
len = 0;
buf[0] = 0;
fseek(p, (long)offset, SEEK_SET);
while ((c = fgetc(p)) != EOF) {
buf[len++] = c;