diff options
author | Vadim Yanitskiy <axilirator@gmail.com> | 2018-03-08 21:57:42 +0700 |
---|---|---|
committer | Vadim Yanitskiy <axilirator@gmail.com> | 2018-03-09 04:14:31 +0700 |
commit | 10959cdea2104a6e8c592d590d5b6acf656eb630 (patch) | |
tree | 227b89001c04197fda7cbc7ac72916a13bd596dc /src | |
parent | b42330516f0aa4bdbbef03ad98555498ec16a715 (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.c | 6 |
1 files changed, 4 insertions, 2 deletions
@@ -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; |