commit 4e5c3016932db3364fd09b10f2072b63947c7646
parent fdf324fe1f9d21b2317ccb0f1c85e2f312074b97
Author: Michael Savage <mikejsavage@gmail.com>
Date: Sun, 31 Mar 2019 19:19:45 +0300
Whoops
Diffstat:
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/array.h b/array.h
@@ -470,9 +470,10 @@ static T bilerp01( const array2d< T > arr, float x, float y ) {
}
inline void format( FormatBuffer * fb, array< const char > arr, const FormatOpts & opts ) {
- if( fb->len < fb->capacity ) {
- size_t len = min( arr.n + 1, fb->capacity - fb->len );
- strlcpy( fb->buf + fb->len, arr.ptr(), len );
+ if( fb->len < fb->capacity - 1 ) {
+ size_t len = min2( span.n, fb->capacity - fb->len - 1 );
+ memcpy( fb->buf + fb->len, span.ptr, len );
+ fb->buf[ fb->len + len ] = '\0';
}
fb->len += arr.n;
}