From: Ondřej Surý Date: Tue, 23 Jul 2019 14:56:26 +0000 (-0400) Subject: Use coccinelle to cleanup the failure handling blocks from isc_mem_allocate X-Git-Tag: v9.15.3~32^2~5 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=601cb4e4ccfad09ff441518421a15700231772da;p=thirdparty%2Fbind9.git Use coccinelle to cleanup the failure handling blocks from isc_mem_allocate --- diff --git a/bin/dig/dighost.c b/bin/dig/dighost.c index c3e553b7abc..b20cb05c9c6 100644 --- a/bin/dig/dighost.c +++ b/bin/dig/dighost.c @@ -446,9 +446,6 @@ make_server(const char *servname, const char *userarg) { debug("make_server(%s)", servname); srv = isc_mem_allocate(mctx, sizeof(struct dig_server)); - if (srv == NULL) - fatal("memory allocation failure in %s:%d", - __FILE__, __LINE__); strlcpy(srv->servername, servname, MXNAME); strlcpy(srv->userarg, userarg, MXNAME); ISC_LINK_INIT(srv, link); @@ -576,9 +573,6 @@ make_empty_lookup(void) { INSIST(!free_now); looknew = isc_mem_allocate(mctx, sizeof(struct dig_lookup)); - if (looknew == NULL) - fatal("memory allocation failure in %s:%d", - __FILE__, __LINE__); looknew->pending = true; looknew->textname[0] = 0; looknew->cmdline[0] = 0; @@ -681,8 +675,6 @@ cloneopts(dig_lookup_t *looknew, dig_lookup_t *lookold) { size_t len = sizeof(looknew->ednsopts[0]) * EDNSOPT_OPTIONS; size_t i; looknew->ednsopts = isc_mem_allocate(mctx, len); - if (looknew->ednsopts == NULL) - fatal("out of memory"); for (i = 0; i < EDNSOPT_OPTIONS; i++) { looknew->ednsopts[i].code = 0; looknew->ednsopts[i].length = 0; @@ -696,10 +688,8 @@ cloneopts(dig_lookup_t *looknew, dig_lookup_t *lookold) { len = lookold->ednsopts[i].length; if (len != 0) { INSIST(lookold->ednsopts[i].value != NULL); - looknew->ednsopts[i].value = - isc_mem_allocate(mctx, len); - if (looknew->ednsopts[i].value == NULL) - fatal("out of memory"); + looknew->ednsopts[i].value = isc_mem_allocate(mctx, + len); memmove(looknew->ednsopts[i].value, lookold->ednsopts[i].value, len); } @@ -805,8 +795,6 @@ clone_lookup(dig_lookup_t *lookold, bool servers) { if (lookold->ecs_addr != NULL) { size_t len = sizeof(isc_sockaddr_t); looknew->ecs_addr = isc_mem_allocate(mctx, len); - if (looknew->ecs_addr == NULL) - fatal("out of memory"); memmove(looknew->ecs_addr, lookold->ecs_addr, len); } @@ -865,9 +853,6 @@ setup_text_key(void) { isc_buffer_putstr(namebuf, keynametext); secretsize = (unsigned int) strlen(keysecret) * 3 / 4; secretstore = isc_mem_allocate(mctx, secretsize); - if (secretstore == NULL) - fatal("memory allocation failure in %s:%d", - __FILE__, __LINE__); isc_buffer_init(&secretbuf, secretstore, secretsize); result = isc_base64_decodestring(keysecret, &secretbuf); if (result != ISC_R_SUCCESS) @@ -957,8 +942,6 @@ parse_netprefix(isc_sockaddr_t **sap, const char *value) { fatal("invalid prefix '%s'\n", value); sa = isc_mem_allocate(mctx, sizeof(*sa)); - if (sa == NULL) - fatal("out of memory"); memset(sa, 0, sizeof(*sa)); if (strcmp(buf, "0") == 0) { @@ -1190,9 +1173,6 @@ static dig_searchlist_t * make_searchlist_entry(char *domain) { dig_searchlist_t *search; search = isc_mem_allocate(mctx, sizeof(*search)); - if (search == NULL) - fatal("memory allocation failure in %s:%d", - __FILE__, __LINE__); strlcpy(search->origin, domain, MXNAME); search->origin[MXNAME-1] = 0; ISC_LINK_INIT(search, link); @@ -1456,9 +1436,7 @@ save_opt(dig_lookup_t *lookup, char *code, char *value) { if (value != NULL) { char *buf; - buf = isc_mem_allocate(mctx, strlen(value)/2 + 1); - if (buf == NULL) - fatal("out of memory"); + buf = isc_mem_allocate(mctx, strlen(value) / 2 + 1); isc_buffer_init(&b, buf, (unsigned int) strlen(value)/2 + 1); result = isc_hex_decodestring(value, &b); check_result(result, "isc_hex_decodestring"); @@ -2489,10 +2467,6 @@ setup_lookup(dig_lookup_t *lookup) { serv = ISC_LIST_NEXT(serv, link)) { query = isc_mem_allocate(mctx, sizeof(dig_query_t)); - if (query == NULL) { - fatal("memory allocation failure in %s:%d", - __FILE__, __LINE__); - } debug("create query %p linked to lookup %p", query, lookup); query->lookup = lookup; query->timer = NULL; diff --git a/bin/dig/nslookup.c b/bin/dig/nslookup.c index 486332ebb31..2363903e9d5 100644 --- a/bin/dig/nslookup.c +++ b/bin/dig/nslookup.c @@ -850,8 +850,6 @@ get_next_command(void) { fflush(stdout); buf = isc_mem_allocate(mctx, COMMSIZE); - if (buf == NULL) - fatal("memory allocation failure"); isc_app_block(); if (interactive) { #ifdef HAVE_READLINE diff --git a/bin/dnssec/dnssec-keyfromlabel.c b/bin/dnssec/dnssec-keyfromlabel.c index ea156c76774..888d34bc09b 100644 --- a/bin/dnssec/dnssec-keyfromlabel.c +++ b/bin/dnssec/dnssec-keyfromlabel.c @@ -368,8 +368,6 @@ main(int argc, char **argv) { len = strlen(label) + 8; l = isc_mem_allocate(mctx, len); - if (l == NULL) - fatal("cannot allocate memory"); snprintf(l, len, "pkcs11:%s", label); isc_mem_free(mctx, label); label = l; diff --git a/bin/dnssec/dnssec-signzone.c b/bin/dnssec/dnssec-signzone.c index cecf7b02be1..c440e8f10c2 100644 --- a/bin/dnssec/dnssec-signzone.c +++ b/bin/dnssec/dnssec-signzone.c @@ -3577,8 +3577,6 @@ main(int argc, char *argv[]) { free_output = true; size = strlen(file) + strlen(".signed") + 1; output = isc_mem_allocate(mctx, size); - if (output == NULL) - fatal("out of memory"); snprintf(output, size, "%s.signed", file); } diff --git a/bin/named/zoneconf.c b/bin/named/zoneconf.c index 1fbd3003cb8..07dffc77b1b 100644 --- a/bin/named/zoneconf.c +++ b/bin/named/zoneconf.c @@ -963,8 +963,6 @@ named_zone_configure(const cfg_obj_t *config, const cfg_obj_t *vconfig, len = strlen(dlzname) + 5; cpval = isc_mem_allocate(mctx, len); - if (cpval == NULL) - return (ISC_R_NOMEMORY); snprintf(cpval, len, "dlz %s", dlzname); } diff --git a/bin/nsupdate/nsupdate.c b/bin/nsupdate/nsupdate.c index 49b79a92900..20f2b24fb3f 100644 --- a/bin/nsupdate/nsupdate.c +++ b/bin/nsupdate/nsupdate.c @@ -514,8 +514,6 @@ setup_keystr(void) { secretlen = strlen(secretstr) * 3 / 4; secret = isc_mem_allocate(gmctx, secretlen); - if (secret == NULL) - fatal("out of memory"); isc_buffer_init(&secretbuf, secret, secretlen); result = isc_base64_decodestring(secretstr, &secretbuf); @@ -584,8 +582,6 @@ read_sessionkey(isc_mem_t *mctx, isc_log_t *lctx) { len = strlen(algorithm) + strlen(mykeyname) + strlen(secretstr) + 3; keystr = isc_mem_allocate(mctx, len); - if (keystr == NULL) - fatal("out of memory"); snprintf(keystr, len, "%s:%s:%s", algorithm, mykeyname, secretstr); setup_keystr(); @@ -1602,8 +1598,6 @@ evaluate_key(char *cmdline) { } secretlen = strlen(secretstr) * 3 / 4; secret = isc_mem_allocate(gmctx, secretlen); - if (secret == NULL) - fatal("out of memory"); isc_buffer_init(&secretbuf, secret, secretlen); result = isc_base64_decodestring(secretstr, &secretbuf); diff --git a/bin/tools/mdig.c b/bin/tools/mdig.c index c2b19a27aea..3c065af7b81 100644 --- a/bin/tools/mdig.c +++ b/bin/tools/mdig.c @@ -845,8 +845,6 @@ newopts(struct query *query) { size_t i; query->ednsopts = isc_mem_allocate(mctx, len); - if (query->ednsopts == NULL) - fatal("out of memory"); for (i = 0; i < EDNSOPTS; i++) { query->ednsopts[i].code = 0; @@ -880,10 +878,7 @@ save_opt(struct query *query, char *code, char *value) { if (value != NULL) { char *buf; - buf = isc_mem_allocate(mctx, strlen(value)/2 + 1); - if (buf == NULL) { - fatal("out of memory"); - } + buf = isc_mem_allocate(mctx, strlen(value) / 2 + 1); isc_buffer_init(&b, buf, strlen(value)/2 + 1); result = isc_hex_decodestring(value, &b); CHECK("isc_hex_decodestring", result); @@ -923,8 +918,6 @@ parse_netprefix(isc_sockaddr_t **sap, const char *value) { } sa = isc_mem_allocate(mctx, sizeof(*sa)); - if (sa == NULL) - fatal("out of memory"); if (inet_pton(AF_INET6, buf, &in6) == 1) { parsed = true; isc_sockaddr_fromin6(sa, &in6, 0); @@ -1690,17 +1683,11 @@ clone_default_query() { struct query *query; query = isc_mem_allocate(mctx, sizeof(struct query)); - if (query == NULL) - fatal("memory allocation failure in %s:%d", - __FILE__, __LINE__); memmove(query, &default_query, sizeof(struct query)); if (default_query.ecs_addr != NULL) { size_t len = sizeof(isc_sockaddr_t); query->ecs_addr = isc_mem_allocate(mctx, len); - if (query->ecs_addr == NULL) - fatal("memory allocation failure in %s:%d", - __FILE__, __LINE__); memmove(query->ecs_addr, default_query.ecs_addr, len); } diff --git a/contrib/dlz/drivers/dlz_filesystem_driver.c b/contrib/dlz/drivers/dlz_filesystem_driver.c index cec74d73dfb..f21670cd3fc 100644 --- a/contrib/dlz/drivers/dlz_filesystem_driver.c +++ b/contrib/dlz/drivers/dlz_filesystem_driver.c @@ -277,16 +277,7 @@ create_path(const char *zone, const char *host, const char *client, if (cd->splitcnt > 0) pathsize += len/cd->splitcnt; - tmpPath = isc_mem_allocate(named_g_mctx , pathsize * sizeof(char)); - if (tmpPath == NULL) { - /* write error message */ - isc_log_write(dns_lctx, DNS_LOGCATEGORY_DATABASE, - DNS_LOGMODULE_DLZ, ISC_LOG_ERROR, - "Filesystem driver unable to " - "allocate memory in create_path()."); - result = ISC_R_NOMEMORY; - goto cleanup_mem; - } + tmpPath = isc_mem_allocate(named_g_mctx, pathsize * sizeof(char)); /* * build path string. diff --git a/contrib/dlz/drivers/dlz_ldap_driver.c b/contrib/dlz/drivers/dlz_ldap_driver.c index e8e5566f2a0..7b9b676df84 100644 --- a/contrib/dlz/drivers/dlz_ldap_driver.c +++ b/contrib/dlz/drivers/dlz_ldap_driver.c @@ -363,14 +363,6 @@ ldap_process_results(LDAP *dbc, LDAPMessage *msg, char ** attrs, /* allocate memory for data string */ data = isc_mem_allocate(named_g_mctx, len + 1); - if (data == NULL) { - isc_log_write(dns_lctx, DNS_LOGCATEGORY_DATABASE, - DNS_LOGMODULE_DLZ, ISC_LOG_ERROR, - "LDAP driver unable to allocate memory " - "while processing results"); - result = ISC_R_FAILURE; - goto cleanup; - } /* * Make sure data is null termed at the beginning so diff --git a/contrib/dlz/drivers/dlz_mysql_driver.c b/contrib/dlz/drivers/dlz_mysql_driver.c index d108773b206..da1c9393c01 100644 --- a/contrib/dlz/drivers/dlz_mysql_driver.c +++ b/contrib/dlz/drivers/dlz_mysql_driver.c @@ -99,9 +99,7 @@ mysqldrv_escape_string(MYSQL *mysql, const char *instr) { len = strlen(instr); - outstr = isc_mem_allocate(named_g_mctx ,(2 * len * sizeof(char)) + 1); - if (outstr == NULL) - return NULL; + outstr = isc_mem_allocate(named_g_mctx, (2 * len * sizeof(char)) + 1); mysql_real_escape_string(mysql, outstr, instr, len); @@ -426,17 +424,6 @@ mysql_process_rs(dns_sdlzlookup_t *lookup, MYSQL_RES *rs) * term string */ tmpString = isc_mem_allocate(named_g_mctx, len + 1); - if (tmpString == NULL) { - /* major bummer, need more ram */ - isc_log_write(dns_lctx, - DNS_LOGCATEGORY_DATABASE, - DNS_LOGMODULE_DLZ, ISC_LOG_ERROR, - "mysql driver unable " - "to allocate memory for " - "temporary string"); - mysql_free_result(rs); - return (ISC_R_FAILURE); /* Yeah, I'd say! */ - } /* copy field to tmpString */ strcpy(tmpString, safeGet(row[2])); @@ -654,16 +641,6 @@ mysql_allnodes(const char *zone, void *driverarg, void *dbdata, } /* allocate memory, allow for NULL to term string */ tmpString = isc_mem_allocate(named_g_mctx, len + 1); - if (tmpString == NULL) { /* we need more ram. */ - isc_log_write(dns_lctx, - DNS_LOGCATEGORY_DATABASE, - DNS_LOGMODULE_DLZ, ISC_LOG_ERROR, - "mysql driver unable " - "to allocate memory for " - "temporary string"); - mysql_free_result(rs); - return (ISC_R_FAILURE); - } /* copy this field to tmpString */ strcpy(tmpString, safeGet(row[3])); /* concatonate the rest, with spaces between */ diff --git a/contrib/dlz/drivers/dlz_odbc_driver.c b/contrib/dlz/drivers/dlz_odbc_driver.c index 59468054253..c5a1a156f3f 100644 --- a/contrib/dlz/drivers/dlz_odbc_driver.c +++ b/contrib/dlz/drivers/dlz_odbc_driver.c @@ -209,12 +209,6 @@ odbc_connect(odbc_instance_t *dbi, odbc_db_t **dbc) { } } else { ndb = isc_mem_allocate(named_g_mctx, sizeof(odbc_db_t)); - if (ndb == NULL) { - isc_log_write(dns_lctx, DNS_LOGCATEGORY_DATABASE, - DNS_LOGMODULE_DLZ, ISC_LOG_ERROR, - "Odbc driver unable to allocate memory"); - return ISC_R_NOMEMORY; - } memset(ndb, 0, sizeof(odbc_db_t)); } @@ -335,9 +329,7 @@ odbc_escape_string(const char *instr) { len = strlen(instr); - outstr = isc_mem_allocate(named_g_mctx ,(2 * len * sizeof(char)) + 1); - if (outstr == NULL) - return NULL; + outstr = isc_mem_allocate(named_g_mctx, (2 * len * sizeof(char)) + 1); odbc_makesafe(outstr, instr, len); @@ -715,8 +707,6 @@ odbc_getManyFields(SQLHSTMT *stmnt, SQLSMALLINT startField, /* allow for a "\n" at the end of the string/ */ data = isc_mem_allocate(named_g_mctx, ++totSize); - if (data == NULL) - return ISC_R_NOMEMORY; result = ISC_R_FAILURE; diff --git a/contrib/dlz/drivers/dlz_postgres_driver.c b/contrib/dlz/drivers/dlz_postgres_driver.c index 734a53c79cc..3bd72b59eec 100644 --- a/contrib/dlz/drivers/dlz_postgres_driver.c +++ b/contrib/dlz/drivers/dlz_postgres_driver.c @@ -240,9 +240,7 @@ postgres_escape_string(const char *instr) { len = strlen(instr); - outstr = isc_mem_allocate(named_g_mctx ,(2 * len * sizeof(char)) + 1); - if (outstr == NULL) - return NULL; + outstr = isc_mem_allocate(named_g_mctx, (2 * len * sizeof(char)) + 1); postgres_makesafe(outstr, instr, len); /* PQescapeString(outstr, instr, len); */ @@ -676,17 +674,6 @@ postgres_process_rs(dns_sdlzlookup_t *lookup, PGresult *rs) * term string */ tmpString = isc_mem_allocate(named_g_mctx, len + 1); - if (tmpString == NULL) { - /* major bummer, need more ram */ - isc_log_write(dns_lctx, - DNS_LOGCATEGORY_DATABASE, - DNS_LOGMODULE_DLZ, ISC_LOG_ERROR, - "Postgres driver unable to " - "allocate memory for " - "temporary string"); - PQclear(rs); - return (ISC_R_FAILURE); /* Yeah, I'd say! */ - } /* copy field to tmpString */ strcpy(tmpString, PQgetvalue(rs, i, 2)); /* @@ -906,16 +893,6 @@ postgres_allnodes(const char *zone, void *driverarg, void *dbdata, } /* allocate memory, allow for NULL to term string */ tmpString = isc_mem_allocate(named_g_mctx, len + 1); - if (tmpString == NULL) { /* we need more ram. */ - isc_log_write(dns_lctx, - DNS_LOGCATEGORY_DATABASE, - DNS_LOGMODULE_DLZ, ISC_LOG_ERROR, - "Postgres driver unable to " - "allocate memory for " - "temporary string"); - PQclear(rs); - return (ISC_R_FAILURE); - } /* copy this field to tmpString */ strcpy(tmpString, PQgetvalue(rs, i, 3)); /* concatonate the rest, with spaces between */ diff --git a/contrib/dlz/drivers/sdlz_helper.c b/contrib/dlz/drivers/sdlz_helper.c index 6f17d07540d..2ca90cc5c6b 100644 --- a/contrib/dlz/drivers/sdlz_helper.c +++ b/contrib/dlz/drivers/sdlz_helper.c @@ -296,9 +296,6 @@ sdlzh_build_querystring(isc_mem_t *mctx, query_list_t *querylist) /* allocate memory for the string */ qs = isc_mem_allocate(mctx, length + 1); - /* couldn't allocate memory, We need more ram! */ - if (qs == NULL) - return NULL; *qs = 0; /* start at the top of the list again */ diff --git a/lib/dns/diff.c b/lib/dns/diff.c index bca15aff89f..3f5d8d2ef64 100644 --- a/lib/dns/diff.c +++ b/lib/dns/diff.c @@ -66,8 +66,6 @@ dns_difftuple_create(isc_mem_t *mctx, */ size = sizeof(*t) + name->length + rdata->length; t = isc_mem_allocate(mctx, size); - if (t == NULL) - return (ISC_R_NOMEMORY); t->mctx = NULL; isc_mem_attach(mctx, &t->mctx); t->op = op; diff --git a/lib/dns/keydata.c b/lib/dns/keydata.c index bd2c144e4b9..8bdd560cadd 100644 --- a/lib/dns/keydata.c +++ b/lib/dns/keydata.c @@ -42,8 +42,6 @@ dns_keydata_todnskey(dns_rdata_keydata_t *keydata, dnskey->data = keydata->data; else { dnskey->data = isc_mem_allocate(mctx, dnskey->datalen); - if (dnskey->data == NULL) - return (ISC_R_NOMEMORY); memmove(dnskey->data, keydata->data, dnskey->datalen); } @@ -73,8 +71,6 @@ dns_keydata_fromdnskey(dns_rdata_keydata_t *keydata, keydata->data = dnskey->data; else { keydata->data = isc_mem_allocate(mctx, keydata->datalen); - if (keydata->data == NULL) - return (ISC_R_NOMEMORY); memmove(keydata->data, dnskey->data, keydata->datalen); } diff --git a/lib/dns/masterdump.c b/lib/dns/masterdump.c index 46fcb49f88b..ff781791dcb 100644 --- a/lib/dns/masterdump.c +++ b/lib/dns/masterdump.c @@ -1804,8 +1804,6 @@ opentmp(isc_mem_t *mctx, dns_masterformat_t format, const char *file, tempnamelen = strlen(file) + 20; tempname = isc_mem_allocate(mctx, tempnamelen); - if (tempname == NULL) - return (ISC_R_NOMEMORY); result = isc_file_mktemplate(file, tempname, tempnamelen); if (result != ISC_R_SUCCESS) diff --git a/lib/dns/name.c b/lib/dns/name.c index bd463d7afc4..03ec8f32c0a 100644 --- a/lib/dns/name.c +++ b/lib/dns/name.c @@ -2402,8 +2402,6 @@ dns_name_tostring(const dns_name_t *name, char **target, isc_mem_t *mctx) { isc_buffer_usedregion(&buf, ®); p = isc_mem_allocate(mctx, reg.length + 1); - if (p == NULL) - return (ISC_R_NOMEMORY); memmove(p, (char *) reg.base, (int) reg.length); p[reg.length] = '\0'; diff --git a/lib/dns/openssl_link.c b/lib/dns/openssl_link.c index eace2c701d5..364168f328f 100644 --- a/lib/dns/openssl_link.c +++ b/lib/dns/openssl_link.c @@ -113,8 +113,6 @@ dst__openssl_init(isc_mem_t *mctx, const char *engine) { #if OPENSSL_VERSION_NUMBER < 0x10100000L || defined(LIBRESSL_VERSION_NUMBER) nlocks = CRYPTO_num_locks(); locks = isc_mem_allocate(dst__mctx, sizeof(isc_mutex_t) * nlocks); - if (locks == NULL) - return (ISC_R_NOMEMORY); isc_mutexblock_init(locks, nlocks); CRYPTO_set_locking_callback(lock_callback); # if defined(LIBRESSL_VERSION_NUMBER) diff --git a/lib/dns/rdata.c b/lib/dns/rdata.c index b88df968e19..bbbc33e8a99 100644 --- a/lib/dns/rdata.c +++ b/lib/dns/rdata.c @@ -387,8 +387,7 @@ mem_maybedup(isc_mem_t *mctx, void *source, size_t length) { if (mctx == NULL) return (source); copy = isc_mem_allocate(mctx, length); - if (copy != NULL) - memmove(copy, source, length); + memmove(copy, source, length); return (copy); } diff --git a/lib/dns/ssu_external.c b/lib/dns/ssu_external.c index 95f2c2ca5c9..6e49aabd142 100644 --- a/lib/dns/ssu_external.c +++ b/lib/dns/ssu_external.c @@ -190,10 +190,6 @@ dns_ssu_external_match(const dns_name_t *identity, /* format the buffer */ data = isc_mem_allocate(mctx, req_len); - if (data == NULL) { - close(fd); - return (false); - } isc_buffer_init(&buf, data, req_len); isc_buffer_putuint32(&buf, SSU_EXTERNAL_VERSION); diff --git a/lib/dns/zone.c b/lib/dns/zone.c index 85ff3afbbd7..ed99c4928b2 100644 --- a/lib/dns/zone.c +++ b/lib/dns/zone.c @@ -1421,7 +1421,7 @@ dns_zone_getdbtype(dns_zone_t *zone, char ***argv, isc_mem_t *mctx) { for (i = 0; i < zone->db_argc; i++) size += strlen(zone->db_argv[i]) + 1; mem = isc_mem_allocate(mctx, size); - if (mem != NULL) { + { tmp = mem; tmp2 = mem; base = mem; @@ -1432,8 +1432,7 @@ dns_zone_getdbtype(dns_zone_t *zone, char ***argv, isc_mem_t *mctx) { tmp2 += strlen(tmp2) + 1; } *tmp = NULL; - } else - result = ISC_R_NOMEMORY; + } UNLOCK_ZONE(zone); *argv = mem; return (result); @@ -1671,8 +1670,6 @@ default_journal(dns_zone_t *zone) { /* Calculate string length including '\0'. */ int len = strlen(zone->masterfile) + sizeof(".jnl"); journal = isc_mem_allocate(zone->mctx, len); - if (journal == NULL) - return (ISC_R_NOMEMORY); strlcpy(journal, zone->masterfile, len); strlcat(journal, ".jnl", len); } else { @@ -19701,8 +19698,6 @@ dns_zone_getincludes(dns_zone_t *zone, char ***includesp) { goto done; array = isc_mem_allocate(zone->mctx, sizeof(char *) * zone->nincludes); - if (array == NULL) - goto done; for (include = ISC_LIST_HEAD(zone->includes); include != NULL; include = ISC_LIST_NEXT(include, link)) { diff --git a/lib/isc/unix/file.c b/lib/isc/unix/file.c index 4c85dffd98b..65aebdf24fe 100644 --- a/lib/isc/unix/file.c +++ b/lib/isc/unix/file.c @@ -629,8 +629,7 @@ isc_file_splitpath(isc_mem_t *mctx, const char *path, char **dirname, } else if (slash != NULL) { file = ++slash; dir = isc_mem_allocate(mctx, slash - path); - if (dir != NULL) - strlcpy(dir, path, slash - path); + strlcpy(dir, path, slash - path); } else { file = path; dir = isc_mem_strdup(mctx, "."); diff --git a/lib/isc/win32/file.c b/lib/isc/win32/file.c index 20927c622cc..ad5ba506913 100644 --- a/lib/isc/win32/file.c +++ b/lib/isc/win32/file.c @@ -714,8 +714,7 @@ isc_file_splitpath(isc_mem_t *mctx, const char *path, char **dirname, } else if (slash != NULL) { file = ++slash; dir = isc_mem_allocate(mctx, slash - path); - if (dir != NULL) - strlcpy(dir, path, slash - path); + strlcpy(dir, path, slash - path); } else { file = path; dir = isc_mem_strdup(mctx, ".");