From: Amos Jeffries Date: Sat, 6 Aug 2016 05:55:37 +0000 (+1200) Subject: Cleanup: check URN list before using it X-Git-Tag: SQUID_4_0_14~52 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=892ee3d0050c4258deb239b4670004c9df68925f;p=thirdparty%2Fsquid.git Cleanup: check URN list before using it The check should not be needed, the URN parse function always allocates. But do it at the right time even so. Detected by Coverity Scan. Issue 434062 --- diff --git a/src/urn.cc b/src/urn.cc index 6b739aedde..62269a6a11 100644 --- a/src/urn.cc +++ b/src/urn.cc @@ -318,12 +318,7 @@ urnHandleReply(void *data, StoreIOBuffer result) urls = urnParseReply(s, urnState->request->method); - for (i = 0; NULL != urls[i].url; ++i) - ++urlcnt; - - debugs(53, 3, "urnFindMinRtt: Counted " << i << " URLs"); - - if (urls == NULL) { /* unknown URN error */ + if (!urls) { /* unknown URN error */ debugs(52, 3, "urnTranslateDone: unknown URN " << e->url()); err = new ErrorState(ERR_URN_RESOLVE, Http::scNotFound, urnState->request.getRaw()); err->url = xstrdup(e->url()); @@ -332,6 +327,11 @@ urnHandleReply(void *data, StoreIOBuffer result) return; } + for (i = 0; urls[i].url; ++i) + ++urlcnt; + + debugs(53, 3, "urnFindMinRtt: Counted " << i << " URLs"); + min_u = urnFindMinRtt(urls, urnState->request->method, NULL); qsort(urls, urlcnt, sizeof(*urls), url_entry_sort); e->buffer();