diff --git a/ChangeLog b/ChangeLog index d02c235..35678de 100644 --- a/ChangeLog +++ b/ChangeLog @@ -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 diff --git a/src/ntoa.c b/src/ntoa.c index d00faae..d3b952d 100644 --- a/src/ntoa.c +++ b/src/ntoa.c @@ -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;