diff --git a/ext/uri/uriparser/include/uriparser/Uri.h b/ext/uri/uriparser/include/uriparser/Uri.h index f0f2ad9a34bd0..9f08559a1858f 100644 --- a/ext/uri/uriparser/include/uriparser/Uri.h +++ b/ext/uri/uriparser/include/uriparser/Uri.h @@ -334,6 +334,10 @@ URI_PUBLIC int URI_FUNC(ParseSingleUriExMm)(URI_TYPE(Uri) * uri, * itself is not freed, only its members. * Uses default libc-based memory manager. * + * @remarks + * Calling on an all-zeros structure (e.g. through memset or calloc) is safe.
+ * Calling on an uninitialized structure is not safe. + * * @param uri INOUT: %URI structure whose members should be freed * * @see uriFreeUriMembersMmA @@ -348,6 +352,10 @@ URI_PUBLIC void URI_FUNC(FreeUriMembers)(URI_TYPE(Uri) * uri); * of the %URI structure. Note that the structure * itself is not freed, only its members. * + * @remarks + * Calling on an all-zeros structure (e.g. through memset or calloc) is safe.
+ * Calling on an uninitialized structure is not safe. + * * @param uri INOUT: %URI structure whose members should be freed * @param memory IN: Memory manager to use, NULL for default libc * @return 0 on success, error code otherwise diff --git a/ext/uri/uriparser/src/UriCopy.c b/ext/uri/uriparser/src/UriCopy.c index 0974ec5c0406d..103e2e7796751 100644 --- a/ext/uri/uriparser/src/UriCopy.c +++ b/ext/uri/uriparser/src/UriCopy.c @@ -111,6 +111,8 @@ int URI_FUNC(CopyUriMm)(URI_TYPE(Uri) * destUri, URI_CHECK_MEMORY_MANAGER(memory); /* may return */ + URI_FUNC(ResetUri)(destUri); + if (URI_FUNC(CopyRangeAsNeeded)(&destUri->scheme, &sourceUri->scheme, URI_FALSE, memory) == URI_FALSE) { return URI_ERROR_MALLOC; } @@ -153,7 +155,10 @@ int URI_FUNC(CopyUriMm)(URI_TYPE(Uri) * destUri, *(destUri->hostData.ip6) = *(sourceUri->hostData.ip6); } - if (URI_FUNC(CopyRangeAsNeeded)(&destUri->hostData.ipFuture, &sourceUri->hostData.ipFuture, URI_FALSE, memory) == URI_FALSE) { + if (sourceUri->hostData.ipFuture.first != NULL && sourceUri->hostText.first == sourceUri->hostData.ipFuture.first) { + destUri->hostData.ipFuture.first = destUri->hostText.first; + destUri->hostData.ipFuture.afterLast = destUri->hostText.afterLast; + } else if (URI_FUNC(CopyRangeAsNeeded)(&destUri->hostData.ipFuture, &sourceUri->hostData.ipFuture, URI_FALSE, memory) == URI_FALSE) { URI_FUNC(PreventLeakageAfterCopy)(destUri, doneMask, memory); return URI_ERROR_MALLOC; } diff --git a/sapi/fpm/tests/socket-uds-too-long-filename-start.phpt b/sapi/fpm/tests/socket-uds-too-long-filename-start.phpt index a7b43d9519b0a..1baf47a466a42 100644 --- a/sapi/fpm/tests/socket-uds-too-long-filename-start.phpt +++ b/sapi/fpm/tests/socket-uds-too-long-filename-start.phpt @@ -40,11 +40,7 @@ $tester->expectLogPattern( $files = glob($socketFilePrefix . '*'); -if ($files === []) { - echo 'Socket files were not found.' . PHP_EOL; -} - -if ($socketFile === $files[0]) { +if (isset($files[0]) && $socketFile === $files[0]) { // this means the socket file path length is not an issue (anymore). Might be not long enough echo 'Socket file is the same as configured.' . PHP_EOL; }