From c0ead185cc44359ecb406e9f7e21b964393f96d8 Mon Sep 17 00:00:00 2001
From: "D. Richard Hipp" <drh@hwaci.com>
Date: Thu, 11 Oct 2018 10:37:24 +0000
Subject: [PATCH 0453/1009] In the CLI, fix a file descriptor leak following
 OOM and a missing va_end() call.

---
 src/shell.c.in | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/shell.c.in b/src/shell.c.in
index a5ab143..c1db72c 100644
--- a/src/shell.c.in
+++ b/src/shell.c.in
@@ -3592,7 +3592,7 @@ static char *readFile(const char *zName, int *pnByte){
   nIn = ftell(in);
   rewind(in);
   pBuf = sqlite3_malloc64( nIn+1 );
-  if( pBuf==0 ) return 0;
+  if( pBuf==0 ){ fclose(in); return 0; }
   nRead = fread(pBuf, nIn, 1, in);
   fclose(in);
   if( nRead!=1 ){
@@ -4976,6 +4976,7 @@ static void shellPreparePrintf(
     char *z;
     va_start(ap, zFmt);
     z = sqlite3_vmprintf(zFmt, ap);
+    va_end(ap);
     if( z==0 ){
       *pRc = SQLITE_NOMEM;
     }else{
-- 
1.8.3.1

