[vlc-commits] WinRT: release the CryptographicBufferStatics and Buffer instances

Jean-Baptiste Kempf git at videolan.org
Tue Jul 23 14:50:34 CEST 2013


vlc | branch: master | Jean-Baptiste Kempf <jb at videolan.org> | Tue Jul 23 14:49:49 2013 +0200| [419af7e0603f73e4eed761d653888bf39bcf6f6e] | committer: Jean-Baptiste Kempf

WinRT: release the CryptographicBufferStatics and Buffer instances

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=419af7e0603f73e4eed761d653888bf39bcf6f6e
---

 src/win32/rand.c |    8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/src/win32/rand.c b/src/win32/rand.c
index 886ace8..948daea 100644
--- a/src/win32/rand.c
+++ b/src/win32/rand.c
@@ -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 */



More information about the vlc-commits mailing list