php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login

Patch getrecord-delimiter-search-fix for Streams related Bug #63240

Patch version 2012-10-09 09:02 UTC

Return to Bug #63240 | Download this patch
Patch Revisions:

Developer: datibbaw@php.net

*** main/streams/streams.c      2012-06-13 12:54:23.000000000 +0800
--- mystreams.c 2012-10-09 17:00:12.000000000 +0800
***************
*** 1017,1022 ****
--- 1017,1027 ----
                return memchr(&stream->readbuf[stream->readpos + skiplen],
                        delim[0], seek_len - skiplen);
        } else {
+               if (skiplen) {
+                       /* left part of the delimiter may still remain in the buffer,
+                       rewind up to <delim_len - 1>*/
+                       skiplen -= MIN(skiplen, delim_len - 1);
+               }
                return php_memnstr((char*)&stream->readbuf[stream->readpos + skiplen],
                                delim, delim_len,
                                (char*)&stream->readbuf[stream->readpos + seek_len]);
 
PHP Copyright © 2001-2014 The PHP Group
All rights reserved.
Last updated: Sun Apr 20 01:02:05 2014 UTC