]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
url: fix `-Wzero-length-array` with no protocols
authorViktor Szakats <commit@vsz.me>
Thu, 16 Nov 2023 18:52:13 +0000 (18:52 +0000)
committerViktor Szakats <commit@vsz.me>
Fri, 17 Nov 2023 11:26:40 +0000 (11:26 +0000)
Fixes:
```
./lib/url.c:178:56: warning: use of an empty initializer is a C2x extension [-Wc2x-extensions]
  178 | static const struct Curl_handler * const protocols[] = {
      |                                                        ^
./lib/url.c:178:56: warning: zero size arrays are an extension [-Wzero-length-array]
```

Closes #12344

lib/url.c

index c7e1cd8e1f718a79f30596cedb2c2499761c2770..187dcda9afa27c913a93ee67cc6f37ac7b0b575d 100644 (file)
--- a/lib/url.c
+++ b/lib/url.c
@@ -288,6 +288,8 @@ static const struct Curl_handler * const protocols[] = {
 #ifndef CURL_DISABLE_DICT
   &Curl_handler_dict,
 #endif
+
+  NULL
 };
 
 void Curl_freeset(struct Curl_easy *data)
@@ -1594,7 +1596,7 @@ const struct Curl_handler *Curl_getn_scheme_handler(const char *scheme,
   size_t i;
   /* Scan protocol handler table and match against 'scheme'. The handler may
      be changed later when the protocol specific setup function is called. */
-  for(i = 0; i < ARRAYSIZE(protocols); ++i)
+  for(i = 0; i < ARRAYSIZE(protocols) - 1; ++i)
     if(strncasecompare(protocols[i]->scheme, scheme, len) &&
        !protocols[i]->scheme[len])
       /* Protocol found in table. */