]> git.ipfire.org Git - thirdparty/git.git/commitdiff
relative_url(): fix incorrect condition
authorJohannes Schindelin <johannes.schindelin@gmx.de>
Wed, 15 Jun 2022 23:35:44 +0000 (23:35 +0000)
committerJunio C Hamano <gitster@pobox.com>
Thu, 16 Jun 2022 20:22:03 +0000 (13:22 -0700)
In 63e95beb085c (submodule: port resolve_relative_url from shell to C,
2016-04-15), we added a loop over `url` where we are looking for `../`
or `./` components.

The loop condition we used is the pointer `url` itself, which is clearly
not what we wanted.

Pointed out by Coverity.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
remote.c

index 9b9bbfe80ec2ef376b79f71e023471d1a5018eef..bded6acbfe834d9d0e74af645c55bfa7e766f049 100644 (file)
--- a/remote.c
+++ b/remote.c
@@ -2846,7 +2846,7 @@ char *relative_url(const char *remote_url, const char *url,
         * When the url starts with '../', remove that and the
         * last directory in remoteurl.
         */
-       while (url) {
+       while (*url) {
                if (starts_with_dot_dot_slash_native(url)) {
                        url += 3;
                        colonsep |= chop_last_dir(&remoteurl, is_relative);