]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
Make it clear to coverity we aren't leaking in protover_all_supported()
authorNick Mathewson <nickm@torproject.org>
Thu, 11 Apr 2019 21:51:11 +0000 (17:51 -0400)
committerNick Mathewson <nickm@torproject.org>
Thu, 11 Apr 2019 21:51:11 +0000 (17:51 -0400)
The logic here should be "use versions or free it".  The "free it"
part was previously in a kind of obfuscated place, so coverity
wasn't sure it was invoked as appropriate.  CID 1437436.

src/core/or/protover.c

index 53709ad002b4ffec015e6a4e0f77e345170cc031..1edf78ec875f451e8e3dcb31312688dfff150060 100644 (file)
@@ -820,6 +820,8 @@ protover_all_supported(const char *s, char **missing_out)
        * ones and, if so, add them to unsupported->ranges. */
       if (versions->low != 0 && versions->high != 0) {
         smartlist_add(unsupported->ranges, versions);
+      } else {
+        tor_free(versions);
       }
       /* Finally, if we had something unsupported, add it to the list of
        * missing_some things and mark that there was something missing. */
@@ -828,7 +830,6 @@ protover_all_supported(const char *s, char **missing_out)
         all_supported = 0;
       } else {
         proto_entry_free(unsupported);
-        tor_free(versions);
       }
     } SMARTLIST_FOREACH_END(range);