Fix various memory leaks

Found with clang-tidy
This commit is contained in:
lbonn 2019-09-07 23:41:33 +02:00 committed by Drew DeVault
parent 32caabc7a1
commit a6307aed00
3 changed files with 11 additions and 4 deletions

View file

@ -687,8 +687,10 @@ static ssize_t getline_with_cont(char **lineptr, size_t *line_size, FILE *file,
nread += next_nread - 2;
if ((ssize_t) *line_size < nread + 1) {
*line_size = nread + 1;
char *old_ptr = *lineptr;
*lineptr = realloc(*lineptr, *line_size);
if (!*lineptr) {
free(old_ptr);
nread = -1;
break;
}