DFortune

Unix fortune-cookie parser written in D
git clone git://xatko.vsos.ethz.ch/DFortune.git
Log | Files | Refs

commit 02806a0d5621de1aad0c0d20bfae2fb7f1e89602
parent d2f9db710b1bfd5bd5466bdc770090475a5e903c
Author: Dominik Schmidt <das1993@hotmail.com>
Date:   Sun,  2 Aug 2015 20:14:34 +0200

Properly heap-allocate the buffer for the fortunes.

Diffstat:
dfortune.d | 3+--
1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/dfortune.d b/dfortune.d @@ -74,8 +74,7 @@ class Fortune : RandomAccessFinite!(string){ uint pos=getOffset(i); uint end=getOffset(i+1)-3; //-3 to exclude \n%\n content.seek(pos); - ubyte buf[]; - buf.length=end-pos; + ubyte buf[]=new ubyte[end-pos]; content.rawRead(buf); if(src==dst){ return cast(string) buf;