fix potential memory leak with converting byte arrays to bitmaps

This commit is contained in:
Jonathan Jenne
2020-11-06 11:12:45 +01:00
parent 18482491ab
commit cf7a55203b
4 changed files with 33 additions and 15 deletions

View File

@@ -1,6 +1,17 @@
Module ModuleHelper
Public Function ByteArrayToBitmap(bytearray() As Byte) As Bitmap
Return New Bitmap(New System.IO.MemoryStream(bytearray))
Try
Dim oBitmap As Bitmap
Using oStream As New IO.MemoryStream(bytearray)
oBitmap = New Bitmap(oStream)
End Using
Return oBitmap
Catch ex As Exception
LOGGER.Error(ex)
Return Nothing
End Try
End Function
Public Function StringToByteArray(ByVal hex As String) As Byte()