Commits

Ruslan Osmanov committed 653b9bf

Refact: automatically set the upper bound of EventBuffer::search to the buffer length, if it is greater then the length

  • Participants
  • Parent commits 20130fd

Comments (0)

Files changed (4)

File classes/buffer.c

 			&& _get_pos(&ptr_start, start_pos, b->buf TSRMLS_CC) == FAILURE) {
 		start_pos = -1;
 	}
-	if (end_pos != -1
-			&& _get_pos(&ptr_end, end_pos, b->buf TSRMLS_CC) == FAILURE) {
+	if (end_pos != -1 &&
+		 	(end_pos > evbuffer_get_length(b->buf)
+			 || _get_pos(&ptr_end, end_pos, b->buf TSRMLS_CC) == FAILURE)) {
 		end_pos = -1;
 	}
 
   <date>2013-03-30</date>
   <!--{{{ Current version -->
   <version>
-    <release>1.5.2</release>
-    <api>1.5.0</api>
+    <release>1.6.0</release>
+    <api>1.6.0</api>
   </version>
   <stability>
     <release>stable</release>
   Fix: bug #64551 with build failed on Mac OS X
   Fix: address argument of the listener accept callback contained garbage in case of a client connected via UNIX domain socket
   Add: EventBuffer::write, EventUtil::setSocketOption methods and some constants
+  Refact: automatically set the upper bound of EventBuffer::search to the buffer length, if it is greater then the length
   ]]></notes>
   <!--}}}-->
   <!--{{{ Contents -->
   </extsrcrelease>
   <!--{{{ changelog-->
   <changelog>
-    <!--{{{ 1.5.2 -->
+    <!--{{{ 1.6.0 -->
     <release>
       <version>
-        <release>1.5.2</release>
+        <release>1.6.0</release>
         <api>1.5.0</api>
       </version>
       <stability>
   Fix: bug #64551 with build failed on Mac OS X
   Fix: address argument of the listener accept callback contained garbage in case of a client connected via UNIX domain socket
   Add: EventBuffer::write, EventUtil::setSocketOption methods and some constants
+  Refact: automatically set the upper bound of EventBuffer::search to the buffer length, if it is greater then the length
   ]]></notes>
     </release>
     <!--}}}-->
 #ifndef PHP_EVENT_H
 #define PHP_EVENT_H
 
-#define PHP_EVENT_VERSION "1.5.2"
+#define PHP_EVENT_VERSION "1.6.0"
 
 #define PHP_EVENT_SUN_PREFIX "unix:"
 

File tests/08-buffer.phpt

 		echo $j, ' ', $tmp == substr($s, $i, 4) ? "ok" : "failed", PHP_EOL;
 	}
 }
+
+$b3 = new EventBuffer();
+$b3->add("123");
+echo "$j ", $b3->search("23", 1, 10) == 1 ? "ok" : "failed", PHP_EOL;
 ?>
 --EXPECT--
 1 ok
 5 ok
 6 ok
 7 ok
+8 ok