Bug 629611. Fix file handle leak, compiler warnings. r=joedrew, a=joedrew
authorJohn Daggett <jdaggett@mozilla.com>
Tue, 08 Feb 2011 15:02:06 +0900
changeset 62127 26d3a5196a5e8f99f11db92c2e9887972d01dfd8
parent 62126 bb740aa9e48efd0003fbaed25f38aac72e5ecb53
child 62128 6cfd4d2e8932478a2996516ae1451d7d6dbd56d8
push id1
push userroot
push dateTue, 10 Dec 2013 15:46:25 +0000
reviewersjoedrew, joedrew
bugs629611
milestone2.0b12pre
Bug 629611. Fix file handle leak, compiler warnings. r=joedrew, a=joedrew
gfx/thebes/gfxWindowsPlatform.cpp
--- a/gfx/thebes/gfxWindowsPlatform.cpp
+++ b/gfx/thebes/gfxWindowsPlatform.cpp
@@ -731,17 +731,16 @@ gfxWindowsPlatform::GetDLLVersion(const 
     aVersion.Assign(NS_ConvertUTF8toUTF16(buf));
 }
 
 void
 gfxWindowsPlatform::GetFontCacheSize(nsAString& aSize)
 {
     WIN32_FIND_DATAW findFileData;
     HANDLE file;
-    LARGE_INTEGER fileSize;
     WCHAR path[MAX_PATH];
 
     aSize.Assign(L"n/a");
 
     if (FAILED(SHGetFolderPathW(NULL, CSIDL_WINDOWS, NULL, 0, path))) {
         return;
     }
 
@@ -752,18 +751,19 @@ gfxWindowsPlatform::GetFontCacheSize(nsA
         return;
     }
      
     WCHAR size[256];
 
     double sizeMB = (double(findFileData.nFileSizeLow) +
                      findFileData.nFileSizeHigh * (double(MAXDWORD) + 1))
                     / 1000000.0;
-    swprintf(size, L"%.2f MB", sizeMB);
+    swprintf_s(size, sizeof(size), L"%.2f MB", sizeMB);
     aSize.Assign(size);
+    FindClose(file);
 }
 
 void
 gfxWindowsPlatform::FontsPrefsChanged(nsIPrefBranch *aPrefBranch, const char *aPref)
 {
     PRBool clearTextFontCaches = PR_TRUE;
 
     gfxPlatform::FontsPrefsChanged(aPrefBranch, aPref);