summaryrefslogtreecommitdiff
path: root/usr/src/lib/libdemangle/common/util.c
diff options
context:
space:
mode:
authorDan McDonald <danmcd@joyent.com>2021-05-14 12:00:48 -0400
committerDan McDonald <danmcd@joyent.com>2021-05-14 12:00:48 -0400
commit1a25930b922d3fede4a252f4f2e0ecb8de2656cb (patch)
treea2ff441f85489691a94f13a644cb7cfe10b81f9e /usr/src/lib/libdemangle/common/util.c
parent3aa01401155d92a38a0d4e107043c130432e4a43 (diff)
parent1cd083931cfd3fb8617c1178f62bce417cfa6af2 (diff)
downloadillumos-joyent-1a25930b922d3fede4a252f4f2e0ecb8de2656cb.tar.gz
[illumos-gate merge]
commit 1cd083931cfd3fb8617c1178f62bce417cfa6af2 13780 Add support for rust v0 mangling format commit 4fe48c6ec9f06cbcce19c4cf97f662b64efde582 13798 loader: Update the EFI timer to be called once a second commit 9e3493cb8a0cfe96c9aef9b7da42c6c9b5c24b43 13374 Port L2ARC Improvements from OpenZFS
Diffstat (limited to 'usr/src/lib/libdemangle/common/util.c')
-rw-r--r--usr/src/lib/libdemangle/common/util.c22
1 files changed, 21 insertions, 1 deletions
diff --git a/usr/src/lib/libdemangle/common/util.c b/usr/src/lib/libdemangle/common/util.c
index 739c554826..17eefe82d7 100644
--- a/usr/src/lib/libdemangle/common/util.c
+++ b/usr/src/lib/libdemangle/common/util.c
@@ -14,7 +14,8 @@
* Copyright 2019, Joyent, Inc.
*/
-#include <sys/debug.h>
+#include <errno.h>
+#include <limits.h>
#include <stdlib.h>
#include <string.h>
#include "demangle-sys.h"
@@ -42,6 +43,25 @@ zalloc(sysdem_ops_t *ops, size_t len)
return (p);
}
+void *
+xcalloc(sysdem_ops_t *ops, size_t n, size_t elsize)
+{
+ uint64_t sz;
+
+ if (mul_overflow(n, elsize, &sz)) {
+ errno = ENOMEM;
+ return (NULL);
+ }
+
+#ifndef _LP64
+ if (sz > SIZE_MAX) {
+ errno = ENOMEM;
+ return (NULL);
+ }
+#endif
+
+ return (zalloc(ops, sz));
+}
void
xfree(sysdem_ops_t *ops, void *p, size_t len)
{