From: shane Date: Thu, 5 Feb 2009 03:16:20 +0000 (+0000) Subject: Fixed error detection in winTrucate() in os_win.c. Windows version only. Ticket... X-Git-Tag: version-3.6.15~488 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f5d335f851f34d43170628351bea791489369214;p=thirdparty%2Fsqlite.git Fixed error detection in winTrucate() in os_win.c. Windows version only. Ticket #3640. (CVS 6262) FossilOrigin-Name: 82e03f1b5481c6fe5e94976f086e8fe8c99881af --- diff --git a/manifest b/manifest index 6796ad002f..19699d0c7c 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Improved\soverrun\sdetection\sin\smem2.c\s(SQLITE_MEMDEBUG).\s\sPreviously\swas\sonly\schecking\sup\sto\s3\sextra\sbytes\sallocated\sdue\sto\srounding.\s(CVS\s6261) -D 2009-02-05T03:00:06 +C Fixed\serror\sdetection\sin\swinTrucate()\sin\sos_win.c.\s\sWindows\sversion\sonly.\s\sTicket\s#3640.\s(CVS\s6262) +D 2009-02-05T03:16:21 F Makefile.arm-wince-mingw32ce-gcc fcd5e9cd67fe88836360bb4f9ef4cb7f8e2fb5a0 F Makefile.in c7a5a30fb6852bd7839b1024e1661da8549878ee F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654 @@ -142,7 +142,7 @@ F src/os.h f996ab57d2035a20e63173419055608548a834c6 F src/os_common.h 24525d8b7bce66c374dfc1810a6c9043f3359b60 F src/os_os2.c bed77dc26e3a95ce4a204936b9a1ca6fe612fcc5 F src/os_unix.c f0fce3042011d462b8ae633564a5668260bd3636 -F src/os_win.c b83b57c24ec5bca07cb0eca6f620e796209e952f +F src/os_win.c 45cb430884da7e9360a55a0fcd5c2c44c22dd79d F src/pager.c 8c946cca1c1e64bd2d4b15aa431481c96233c826 F src/pager.h 0c9f3520c00d8a3b8e792ca56c9a11b6b02b4b0f F src/parse.y 4f4d16aee0d11f69fec2adb77dac88878043ed8d @@ -701,7 +701,7 @@ F tool/speedtest16.c c8a9c793df96db7e4933f0852abb7a03d48f2e81 F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e -P e420a3cedc7ee086a77cd719f6b9fb85415eb5f3 -R 4a184e6c5bd73985f13d3779f47b3ea6 +P a6fe3d6b02734b23fe067a373c0232024a782a6c +R 44c59b6fa98593f23066b22d11bd7514 U shane -Z c74ee2119d4b4fd3d0ad9086d7b4ece5 +Z dc1ee389fb4cd7e5a18726142b311469 diff --git a/manifest.uuid b/manifest.uuid index 893e1a37de..9930e6c4f5 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -a6fe3d6b02734b23fe067a373c0232024a782a6c \ No newline at end of file +82e03f1b5481c6fe5e94976f086e8fe8c99881af \ No newline at end of file diff --git a/src/os_win.c b/src/os_win.c index 02f4f7333f..2f98ee7185 100644 --- a/src/os_win.c +++ b/src/os_win.c @@ -12,7 +12,7 @@ ** ** This file contains code that is specific to windows. ** -** $Id: os_win.c,v 1.147 2009/02/04 03:59:25 shane Exp $ +** $Id: os_win.c,v 1.148 2009/02/05 03:16:21 shane Exp $ */ #include "sqliteInt.h" #if SQLITE_OS_WIN /* This file is used for windows only */ @@ -727,16 +727,21 @@ static int winTruncate(sqlite3_file *id, sqlite3_int64 nByte){ LONG upperBits = (LONG)((nByte>>32) & 0x7fffffff); LONG lowerBits = (LONG)(nByte & 0xffffffff); winFile *pFile = (winFile*)id; + DWORD error = NO_ERROR; OSTRACE3("TRUNCATE %d %lld\n", pFile->h, nByte); SimulateIOError(return SQLITE_IOERR_TRUNCATE); rc = SetFilePointer(pFile->h, lowerBits, &upperBits, FILE_BEGIN); - if( INVALID_SET_FILE_POINTER != rc ){ + if( INVALID_SET_FILE_POINTER == rc ){ + error = GetLastError(); + } + if( error == NO_ERROR ){ /* SetEndOfFile will fail if nByte is negative */ if( SetEndOfFile(pFile->h) ){ return SQLITE_OK; } + error = GetLastError(); } - pFile->lastErrno = GetLastError(); + pFile->lastErrno = error; return SQLITE_IOERR_TRUNCATE; }