From 892ee3d0050c4258deb239b4670004c9df68925f Mon Sep 17 00:00:00 2001 From: Amos Jeffries Date: Sat, 6 Aug 2016 17:55:37 +1200 Subject: [PATCH] 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 --- src/urn.cc | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) 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(); -- 2.47.2