Skip to content

Commit 32834e3

Browse files
committed
Merge pull request johnsensible#44 from karyon/master
Prevent file leak in 'simple' backend
2 parents 603b487 + d913244 commit 32834e3

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

sendfile/backends/simple.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ def sendfile(request, filename, **kwargs):
1919
statobj[stat.ST_MTIME], statobj[stat.ST_SIZE]):
2020
return HttpResponseNotModified()
2121

22-
response = HttpResponse(File(open(filename, 'rb')).chunks())
22+
with File(open(filename, 'rb')) as f:
23+
response = HttpResponse(f.chunks())
2324

2425
response["Last-Modified"] = http_date(statobj[stat.ST_MTIME])
2526
return response

0 commit comments

Comments
 (0)