Diff options
Diffstat (limited to 'source/shared.c')
| -rw-r--r-- | source/shared.c | 6 |
1 file changed, 2 insertions, 4 deletions
diff --git a/source/shared.c b/source/shared.c index d159a7a..30e2e12 100644 --- a/source/shared.c +++ b/source/shared.c @@ -505,7 +505,7 @@ void cgit_prepare_repo_env(struct cgit_repo *repo) vars[i].name, vars[i].value, strerror(errno), errno); } -int cgit_read_first_line(const char *path, char **buf, size_t *size) +int cgit_read_first_line(const char *path, char **buf) { int fd, err; ssize_t got; @@ -533,12 +533,10 @@ int cgit_read_first_line(const char *path, char **buf, size_t *size) err = errno; free(*buf); *buf = NULL; - *size = 0; close(fd); return err; } - *size = got; - (*buf)[*size] = '\0'; + (*buf)[got] = '\0'; *strchrnul(*buf, '\n') = '\0'; close(fd); return 0; |
