aboutsummaryrefslogtreecommitdiffstats
path: root/aligned_wcsndup.c
diff options
context:
space:
mode:
authorMattias Andrée <maandree@kth.se>2018-12-15 14:56:23 +0100
committerMattias Andrée <maandree@kth.se>2018-12-15 14:56:23 +0100
commitd1122de6bb461e0448897869b4406300c12f259f (patch)
tree031bf1bdb887be786e5bb370c83eb52eef649ddc /aligned_wcsndup.c
parentA bunch of stuff (diff)
downloadlibsimple-d1122de6bb461e0448897869b4406300c12f259f.tar.gz
libsimple-d1122de6bb461e0448897869b4406300c12f259f.tar.bz2
libsimple-d1122de6bb461e0448897869b4406300c12f259f.tar.xz
More tests and fix attributes on wcsndup
Signed-off-by: Mattias Andrée <maandree@kth.se>
Diffstat (limited to 'aligned_wcsndup.c')
-rw-r--r--aligned_wcsndup.c6
1 files changed, 2 insertions, 4 deletions
diff --git a/aligned_wcsndup.c b/aligned_wcsndup.c
index 1839316..90ce7f7 100644
--- a/aligned_wcsndup.c
+++ b/aligned_wcsndup.c
@@ -8,10 +8,8 @@ libsimple_aligned_wcsndup(const wchar_t *s, size_t alignment, size_t n)
{
size_t size;
wchar_t *ret;
- if (LIBSIMPLE_UMUL_OVERFLOW_NONZERO(n + 1, sizeof(wchar_t), &size, SIZE_MAX)) {
- errno = ENOMEM;
- return NULL;
- }
+ n = wcsnlen(s, n);
+ size = (n + 1) * sizeof(wchar_t);
size = size + (alignment - size % alignment) % alignment;
ret = aligned_alloc(alignment, size);
if (!ret)