]> git.sesse.net Git - vlc/commitdiff
WinRT: release the CryptographicBufferStatics and Buffer instances
authorJean-Baptiste Kempf <jb@videolan.org>
Tue, 23 Jul 2013 12:49:49 +0000 (14:49 +0200)
committerJean-Baptiste Kempf <jb@videolan.org>
Tue, 23 Jul 2013 12:49:49 +0000 (14:49 +0200)
src/win32/rand.c

index 886ace88db89cc1e4504ba4c11f66fd314742622..948daea5d1da65ffebcc797dd43ac76062af6943 100644 (file)
@@ -78,12 +78,18 @@ void vlc_rand_bytes (void *buf, size_t len)
 
     IBuffer *buffer = NULL;
     hr = ICryptographicBufferStatics_GenerateRandom(cryptoStatics, len, &buffer);
-    if (hr)
+    if (hr) {
+        ICryptographicBufferStatics_Release(cryptoStatics);
         return;
+    }
+
     UINT32 olength;
     unsigned char *rnd = NULL;
     hr = ICryptographicBufferStatics_CopyToByteArray(cryptoStatics, buffer, &olength, (BYTE**)&rnd);
     memcpy(buf, rnd, len);
+
+    IBuffer_Release(buffer);
+    ICryptographicBufferStatics_Release(cryptoStatics);
 #else
     HCRYPTPROV hProv;
     /* acquire default encryption context */