summaryrefslogtreecommitdiff
path: root/source3/lib/util.c
diff options
context:
space:
mode:
Diffstat (limited to 'source3/lib/util.c')
-rw-r--r--source3/lib/util.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/source3/lib/util.c b/source3/lib/util.c
index ae94b710b2..bf012b9721 100644
--- a/source3/lib/util.c
+++ b/source3/lib/util.c
@@ -1819,6 +1819,17 @@ char *smb_xstrdup(const char *s)
return s1;
}
+/**
+ strndup that aborts on malloc fail.
+**/
+char *smb_xstrndup(const char *s, size_t n)
+{
+ char *s1 = strndup(s, n);
+ if (!s1)
+ smb_panic("smb_xstrndup: malloc fail\n");
+ return s1;
+}
+
/*
vasprintf that aborts on malloc fail
*/