]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Silence cppcheck possible NULL pointer dereference marka-cppcheck-2-6
authorMark Andrews <marka@isc.org>
Fri, 29 Oct 2021 21:28:34 +0000 (08:28 +1100)
committerMark Andrews <marka@isc.org>
Mon, 1 Nov 2021 06:44:23 +0000 (17:44 +1100)
Use isc_region_t instead of isc_textregion_t as ccpcheck marked
tr.base as not initalised.

lib/dns/rdata.c

index a5e7831b06a1337141a7afef935681a01b424efe..fa51b5af7ffefa3c58a227769bd1dd9271eebc56 100644 (file)
@@ -1890,9 +1890,9 @@ inet_totext(int af, uint32_t flags, isc_region_t *src, isc_buffer_t *target) {
         * parsing, so append 0 in that case.
         */
        if (af == AF_INET6 && (flags & DNS_STYLEFLAG_YAML) != 0) {
-               isc_textregion_t tr;
-               isc_buffer_usedregion(target, (isc_region_t *)&tr);
-               if (tr.base[tr.length - 1] == ':') {
+               isc_region_t r;
+               isc_buffer_usedregion(target, &r);
+               if (r.length > 0U && r.base[r.length - 1] == ':') {
                        if (isc_buffer_availablelength(target) == 0) {
                                return (ISC_R_NOSPACE);
                        }