summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorVadim Yanitskiy <axilirator@gmail.com>2018-03-08 21:57:42 +0700
committerVadim Yanitskiy <axilirator@gmail.com>2018-03-09 04:14:31 +0700
commit10959cdea2104a6e8c592d590d5b6acf656eb630 (patch)
tree227b89001c04197fda7cbc7ac72916a13bd596dc /src
parentb42330516f0aa4bdbbef03ad98555498ec16a715 (diff)
src/msgb.c: avoid using internal talloc API
An internal symbol '_talloc_zero' of talloc library was used during a msgb allocation. This is not actually good because: - it may be removed or modified by talloc developers; - the behaviour may be changed by talloc developers; - it's marked as internal using 'underscore'; - there is public API to do the same. So, let's use the public API. Change-Id: I1080c9071e997944cc0f9fc3716129e9395437ad
Diffstat (limited to 'src')
-rw-r--r--src/msgb.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/msgb.c b/src/msgb.c
index 82902b40..844cfc61 100644
--- a/src/msgb.c
+++ b/src/msgb.c
@@ -79,14 +79,16 @@ struct msgb *msgb_alloc(uint16_t size, const char *name)
{
struct msgb *msg;
- msg = _talloc_zero(tall_msgb_ctx, sizeof(*msg) + size, name);
-
+ msg = talloc_named_const(tall_msgb_ctx, sizeof(*msg) + size, name);
if (!msg) {
LOGP(DLGLOBAL, LOGL_FATAL, "Unable to allocate a msgb: "
"name='%s', size=%u\n", name, size);
return NULL;
}
+ /* Manually zero-initialize allocated memory */
+ memset(msg, 0x00, sizeof(*msg) + size);
+
msg->data_len = size;
msg->len = 0;
msg->data = msg->_data;