From 361c60e719bd3202b53300844150c1d020f8e7f9 Mon Sep 17 00:00:00 2001 From: Alex Kotov Date: Tue, 31 May 2022 02:53:18 +0300 Subject: [PATCH] Main: src/ntoa.h: Protect caller from invalid state in case of future assertions --- ChangeLog | 1 + src/ntoa.c | 3 +++ 2 files changed, 4 insertions(+) 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;