You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by jd...@apache.org on 2020/12/20 10:45:35 UTC
[qpid-dispatch] branch master updated: NO-JIRA Use checked
allocation API from DISPATCH-1685 (#948)
This is an automated email from the ASF dual-hosted git repository.
jdanek pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/qpid-dispatch.git
The following commit(s) were added to refs/heads/master by this push:
new 45f586b NO-JIRA Use checked allocation API from DISPATCH-1685 (#948)
45f586b is described below
commit 45f586b72c70053af516851a67af8cafd8a30ec4
Author: Jiri Daněk <jd...@redhat.com>
AuthorDate: Sun Dec 20 11:45:28 2020 +0100
NO-JIRA Use checked allocation API from DISPATCH-1685 (#948)
These are in response to fb-infer warnings of the following kind
/qpid-dispatch/src/router_core/core_events.c:46: error: Null Dereference
pointer `sub` last assigned on line 45 could be null and is dereferenced by call to `memset()` at line 46, column 5.
44. {
45. qdrc_event_subscription_t *sub = NEW(qdrc_event_subscription_t);
46. ZERO(sub);
^
47.
48. sub->context = context;
/qpid-dispatch/src/remote_sasl.c:72: error: Null Dereference
pointer `buffer->start` last assigned on line 71 could be null and is dereferenced by call to `memset()` at line 72, column 5.
70. {
71. buffer->start = malloc(buffer->capacity);
72. memset(buffer->start, 0, buffer->capacity);
^
73. }
74.
---
include/qpid/dispatch/ctools.h | 6 +++---
src/remote_sasl.c | 2 +-
src/router_core/modules/address_lookup_client/lookup_client.c | 2 +-
src/router_node.c | 2 +-
src/server.c | 2 +-
5 files changed, 7 insertions(+), 7 deletions(-)
diff --git a/include/qpid/dispatch/ctools.h b/include/qpid/dispatch/ctools.h
index 08fb471..d2a11e6 100644
--- a/include/qpid/dispatch/ctools.h
+++ b/include/qpid/dispatch/ctools.h
@@ -31,9 +31,9 @@
#define CT_ASSERT(exp) { assert(exp); }
-#define NEW(t) (t*) malloc(sizeof(t))
-#define NEW_ARRAY(t,n) (t*) malloc(sizeof(t)*(n))
-#define NEW_PTR_ARRAY(t,n) (t**) malloc(sizeof(t*)*(n))
+#define NEW(t) (t*) qd_malloc(sizeof(t))
+#define NEW_ARRAY(t,n) (t*) qd_malloc(sizeof(t)*(n))
+#define NEW_PTR_ARRAY(t,n) (t**) qd_malloc(sizeof(t*)*(n))
//
// If available, use aligned_alloc for cache-line-aligned allocations. Otherwise
diff --git a/src/remote_sasl.c b/src/remote_sasl.c
index d24b8a2..d8ffb22 100644
--- a/src/remote_sasl.c
+++ b/src/remote_sasl.c
@@ -68,7 +68,7 @@ typedef struct {
static void allocate_buffer(buffer_t* buffer)
{
- buffer->start = malloc(buffer->capacity);
+ buffer->start = qd_malloc(buffer->capacity);
memset(buffer->start, 0, buffer->capacity);
}
diff --git a/src/router_core/modules/address_lookup_client/lookup_client.c b/src/router_core/modules/address_lookup_client/lookup_client.c
index b835cfb..2c954b3 100644
--- a/src/router_core/modules/address_lookup_client/lookup_client.c
+++ b/src/router_core/modules/address_lookup_client/lookup_client.c
@@ -71,7 +71,7 @@ static char* disambiguated_link_name(qdr_connection_info_t *conn, char *original
{
size_t olen = strlen(original);
size_t clen = strlen(conn->container);
- char *name = (char*) malloc(olen + clen + 2);
+ char *name = (char*) qd_malloc(olen + clen + 2);
memset(name, 0, olen + clen + 2);
strcat(name, original);
name[olen] = '@';
diff --git a/src/router_node.c b/src/router_node.c
index cd4b94c..7d70bd5 100644
--- a/src/router_node.c
+++ b/src/router_node.c
@@ -1463,7 +1463,7 @@ qd_router_t *qd_router(qd_dispatch_t *qd, qd_router_mode_t mode, const char *are
}
size_t dplen = 9 + strlen(area) + strlen(id);
- node_id = (char*) malloc(dplen);
+ node_id = (char*) qd_malloc(dplen);
strcpy(node_id, area);
strcat(node_id, "/");
strcat(node_id, id);
diff --git a/src/server.c b/src/server.c
index 6382025..4c8cb00 100644
--- a/src/server.c
+++ b/src/server.c
@@ -1477,7 +1477,7 @@ void qd_server_run(qd_dispatch_t *qd)
qd_log(qd_server->log_source, QD_LOG_INFO, "Running in DEBUG Mode");
#endif
int n = qd_server->thread_count - 1; /* Start count-1 threads + use current thread */
- sys_thread_t **threads = (sys_thread_t **)calloc(n, sizeof(sys_thread_t*));
+ sys_thread_t **threads = (sys_thread_t **)qd_calloc(n, sizeof(sys_thread_t*));
for (i = 0; i < n; i++) {
threads[i] = sys_thread(thread_run, qd_server);
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org