Main: src/ntoa.h: Protect caller from invalid state in case of future assertions

This commit is contained in:
Alex Kotov 2022-05-31 02:53:18 +03:00
parent c1e7f5e20b
commit 361c60e719
Signed by: kotovalexarian
GPG Key ID: 553C0EBBEB5D5F08
2 changed files with 4 additions and 0 deletions

View File

@ -10,6 +10,7 @@
* include/kernaux/ntoa.h: Functions "kernaux_[u|i]toa16" put default prefix
* include/kernaux/ntoa.h: Add octal functions "kernaux_[u|i]toa8"
* include/kernaux/ntoa.h: Add binary functions "kernaux_[u|i]toa2"
* src/ntoa.h: Protect caller from invalid state in case of future assertions
2022-05-28 Alex Kotov <kotovalexarian@gmail.com>

View File

@ -11,6 +11,9 @@ char *kernaux_utoa(uint64_t value, char *buffer, int base, const char *prefix)
{
KERNAUX_NOTNULL_RETVAL(buffer, NULL);
// Protect caller from invalid state in case of future assertions
*buffer = '\0';
switch (base) {
case 'b': case 'B': base = 2; break;
case 'o': case 'O': base = 8; break;