Re: [sdljava-users] Fix for BufferUtils
Status: Beta
Brought to you by:
ivan_ganza
From: Ivan Z. G. <iva...@ya...> - 2005-04-19 01:38:54
|
Thanks for the patch Robert I've applied it. -Ivan/ Robert Schuster wrote: >-----BEGIN PGP SIGNED MESSAGE----- >Hash: SHA1 > >Hi, >please apply this patch to fix a problem in BufferUtils.readInputStream(). > >The big buffer holding all the data of the smaller ones was not >correctly set into the state where the data could be read afterwards. > >This caused a buffer overflow. Well, just flipping the buffer state >fixes this. > >Along with this small fix I changed the minimum buffer size to 8192 (was >1024) which will cause the creation of fewer intermediate buffer for big >files. > >cu >Robert >-----BEGIN PGP SIGNATURE----- >Version: GnuPG v1.4.1 (GNU/Linux) >Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org > >iD8DBQFCZDCdG9cfwmwwEtoRArIJAJ47sko+U8pihBUvM322WQ/TNsPc6QCgkCrX >fyYHS7d/TKSO3flF2/hbMds= >=eHuJ >-----END PGP SIGNATURE----- > > >------------------------------------------------------------------------ > >Index: src/sdljava/util/BufferUtil.java >=================================================================== >RCS file: /cvsroot/sdljava/sdljava/src/sdljava/util/BufferUtil.java,v >retrieving revision 1.7 >diff -u -r1.7 BufferUtil.java >--- src/sdljava/util/BufferUtil.java 13 Mar 2005 19:44:59 -0000 1.7 >+++ src/sdljava/util/BufferUtil.java 18 Apr 2005 22:02:50 -0000 >@@ -38,7 +38,7 @@ > // float 32 bits > // double 64 bits > >- private static final int BUFFER_SIZE = 1024; >+ private static final int BUFFER_SIZE = 8192; > > /** > * Tries to open the given URL, get its input stream, returns the data in a <I><B>direct</I></B> ByteBuffer >@@ -107,6 +107,9 @@ > } > > list.clear(); >+ >+ // Makes buffer ready for reading later >+ bb.flip(); > > return bb; > } >@@ -168,4 +171,4 @@ > public static CharBuffer createCharBuffer(char[] values) { > return createCharBuffer(values.length).put(values); > } >-} >\ No newline at end of file >+} > > |