-/* $OpenBSD: server_http.c,v 1.150 2022/03/02 11:10:43 florian Exp $ */
+/* $OpenBSD: server_http.c,v 1.151 2022/08/15 09:36:19 op Exp $ */
/*
* Copyright (c) 2020 Matthias Pressfreund <mpfr@fn.de>
free(path);
if (fstat(fd, &sb) < 0) {
log_warn("%s: stat", __func__);
+ close(fd);
return (NULL);
}
if ((ret = calloc(1, sb.st_size + 1)) == NULL)
fatal("calloc");
- if (sb.st_size == 0)
+ if (sb.st_size == 0) {
+ close(fd);
return (ret);
+ }
if (read(fd, ret, sb.st_size) != sb.st_size) {
log_warn("%s: read", __func__);
close(fd);