You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@apr.apache.org by mt...@apache.org on 2021/12/01 13:23:15 UTC

svn commit: r1895464 - /apr/apr/trunk/buckets/apr_brigade.c

Author: mturk
Date: Wed Dec  1 13:23:15 2021
New Revision: 1895464

URL: http://svn.apache.org/viewvc?rev=1895464&view=rev
Log:
Fix pointer arithmetic for 'void *'

Modified:
    apr/apr/trunk/buckets/apr_brigade.c

Modified: apr/apr/trunk/buckets/apr_brigade.c
URL: http://svn.apache.org/viewvc/apr/apr/trunk/buckets/apr_brigade.c?rev=1895464&r1=1895463&r2=1895464&view=diff
==============================================================================
--- apr/apr/trunk/buckets/apr_brigade.c (original)
+++ apr/apr/trunk/buckets/apr_brigade.c Wed Dec  1 13:23:15 2021
@@ -389,19 +389,18 @@ APR_DECLARE(apr_status_t) apr_brigade_sp
 
 #if !APR_HAVE_MEMMEM
 static const void *
-memmem(const void *hay, size_t hay_len, const void *needle, size_t needle_len)
+memmem(const void *_hay, size_t hay_len, const void *needle, size_t needle_len)
 {
-
     if (hay_len < needle_len || !needle_len || !hay_len) {
         return NULL;
     }
     else {
-
         apr_size_t len = hay_len - needle_len + 1;
-        const void *end = hay + hay_len;
+        const apr_byte_t *hay = (apr_byte_t *)_hay;
+        const apr_byte_t *end = hay + hay_len;
 
         while ((hay = memchr(hay, *(char *)needle, len))) {
-            len = end - hay - needle_len + 1;
+            len = (apr_size_t)(end - hay) - needle_len + 1;
 
             if (memcmp(hay, needle, needle_len) == 0 ) {
                 break;