commit 6078fa9b254a689ae50bc8218e66e5bdc05bef36 parent 2bc77b4ce70e2c8477d743febf434265ae55d655 Author: Michael Savage <mikejsavage@gmail.com> Date: Fri, 25 Aug 2017 09:41:39 +0100 Allow ggformat( NULL, 0 ) Diffstat:
ggformat.cc | | | 4 | +++- |
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/ggformat.cc b/ggformat.cc @@ -277,7 +277,9 @@ void ggformat_literals( FormatBuffer * fb, const char * literals, size_t len ) { copied_len++; } fb->len += copied_len; - fb->buf[ fb->len < fb->capacity - 1 ? fb->len : fb->capacity - 1 ] = '\0'; + if( fb->capacity > 0 ) { + fb->buf[ fb->len < fb->capacity - 1 ? fb->len : fb->capacity - 1 ] = '\0'; + } } void ggformat_impl( FormatBuffer * fb, const char * fmt ) {