X Tutup
Skip to content

Commit 3dfeb04

Browse files
committed
hexdecoct: make return parameters of unbase64mem() and unhexmem() optional
Inspired by: systemd#19059
1 parent 205013c commit 3dfeb04

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

src/basic/hexdecoct.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -115,8 +115,6 @@ int unhexmem_full(const char *p, size_t l, bool secure, void **ret, size_t *ret_
115115
uint8_t *z;
116116
int r;
117117

118-
assert(ret);
119-
assert(ret_len);
120118
assert(p || l == 0);
121119

122120
if (l == SIZE_MAX)
@@ -150,8 +148,10 @@ int unhexmem_full(const char *p, size_t l, bool secure, void **ret, size_t *ret_
150148

151149
*z = 0;
152150

153-
*ret_len = (size_t) (z - buf);
154-
*ret = TAKE_PTR(buf);
151+
if (ret_len)
152+
*ret_len = (size_t) (z - buf);
153+
if (ret)
154+
*ret = TAKE_PTR(buf);
155155

156156
return 0;
157157

@@ -705,8 +705,6 @@ int unbase64mem_full(const char *p, size_t l, bool secure, void **ret, size_t *r
705705
int r;
706706

707707
assert(p || l == 0);
708-
assert(ret);
709-
assert(ret_size);
710708

711709
if (l == SIZE_MAX)
712710
l = strlen(p);
@@ -802,8 +800,10 @@ int unbase64mem_full(const char *p, size_t l, bool secure, void **ret, size_t *r
802800

803801
*z = 0;
804802

805-
*ret_size = (size_t) (z - buf);
806-
*ret = TAKE_PTR(buf);
803+
if (ret_size)
804+
*ret_size = (size_t) (z - buf);
805+
if (ret)
806+
*ret = TAKE_PTR(buf);
807807

808808
return 0;
809809

0 commit comments

Comments
 (0)
X Tutup