From 1777a69818610d4ed8a93f661a45219d97e7f6c5 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 29 Mar 2013 06:25:22 +0000 Subject: misc minor edits. - pass string size to BLI_timestr() to avoid possible buffer overrun. - quiet warning for mingw. - include guards for windows utf conversion funcs. - fix for mistage in edge-angle-selection check. - some style cleanup. --- source/blender/blenlib/intern/string.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) (limited to 'source/blender/blenlib/intern/string.c') diff --git a/source/blender/blenlib/intern/string.c b/source/blender/blenlib/intern/string.c index 906a3095f91..ba914944733 100644 --- a/source/blender/blenlib/intern/string.c +++ b/source/blender/blenlib/intern/string.c @@ -490,22 +490,20 @@ int BLI_natstrcmp(const char *s1, const char *s2) return 0; } -void BLI_timestr(double _time, char *str) +void BLI_timestr(double _time, char *str, size_t maxlen) { /* format 00:00:00.00 (hr:min:sec) string has to be 12 long */ int hr = ( (int) _time) / (60 * 60); int min = (((int) _time) / 60 ) % 60; - int sec = ( (int) (_time)) % 60; + int sec = ( (int) _time) % 60; int hun = ( (int) (_time * 100.0)) % 100; - + if (hr) { - sprintf(str, "%.2d:%.2d:%.2d.%.2d", hr, min, sec, hun); + BLI_snprintf(str, maxlen, "%.2d:%.2d:%.2d.%.2d", hr, min, sec, hun); } else { - sprintf(str, "%.2d:%.2d.%.2d", min, sec, hun); + BLI_snprintf(str, maxlen, "%.2d:%.2d.%.2d", min, sec, hun); } - - str[11] = 0; } /* determine the length of a fixed-size string */ -- cgit v1.2.3