2008-09-22 Stephane Delcroix <sdelcroix@novell.com>

* ImageFactory.custom: prevent exception on overread.

svn path=/trunk/exiv2-sharp/; revision=113711
This commit is contained in:
Stephane Delcroix 2008-09-22 12:04:27 +00:00
Родитель 37cd466a7a
Коммит cc49b58b44
2 изменённых файлов: 7 добавлений и 2 удалений

Просмотреть файл

@ -1,3 +1,7 @@
2008-09-22 Stephane Delcroix <sdelcroix@novell.com>
* ImageFactory.custom: prevent exception on overread.
2008-09-22 Stephane Delcroix <sdelcroix@novell.com>
* ImageFactory.custom: OpenAsync (Stream)

Просмотреть файл

@ -77,9 +77,10 @@ public static void OpenAsync (System.IO.Stream stream, object userToken, OpenCom
System.Threading.Thread async_thread = new System.Threading.Thread (delegate (object state) {
object [] args = (object []) state;
try {
byte [] buffer = new byte [stream.Length];
long length = stream.Length;
byte [] buffer = new byte [length];
int offset = 0, count;
while ((count = stream.Read (buffer, offset, 1024)) > 0)
while ((count = stream.Read (buffer, offset, length - offset > 1024 ? 1024 : (int)(length - offset))) > 0)
offset+=count;
Exiv2.Image data = Open (buffer);
OnOpenCompleted (new OpenCompletedEventArgs (data, null, false, args [1]), completed_handler);