]> git.ipfire.org Git - thirdparty/mlmmj.git/commitdiff
memory: fix user after free
authorBaptiste Daroussin <bapt@FreeBSD.org>
Mon, 9 Jan 2023 09:02:23 +0000 (10:02 +0100)
committerBaptiste Daroussin <bapt@FreeBSD.org>
Mon, 9 Jan 2023 09:02:23 +0000 (10:02 +0100)
src/incindexfile.c

index fbc9d2344a321cfb4006c013d8f6968ca765da07..ce85fa2a77141652b3f481335638e48e7a6d496d 100644 (file)
@@ -62,12 +62,13 @@ int incindexfile(int listfd)
                /* eliminate everything which is not a number */
                line[strspn(line, "0123456789")] = '\0';
                index = strtoim(line, 0, INT_MAX, &errstr);
-               free(line);
                if (errstr != NULL) {
                        log_error(LOG_ARGS, "Error reading index file: invalid "
                            "line: %s", line);
+                       free(line);
                        return (0);
                }
+               free(line);
        }
        index++;
        rewind(fp);