Browse code

timecode: set a fixed buffer size of 16B for tc string.

Clément Bœsch authored on 2012/01/12 01:51:57
Showing 3 changed files
... ...
@@ -91,7 +91,7 @@ char *avpriv_timecode_to_string(char *buf, const struct ff_timecode *tc, unsigne
91 91
     ss = frame_num / fps        % 60;
92 92
     mm = frame_num / (fps*60)   % 60;
93 93
     hh = frame_num / (fps*3600) % 24;
94
-    snprintf(buf, sizeof("hh:mm:ss.ff"), "%02d:%02d:%02d%c%02d",
94
+    snprintf(buf, 16, "%02d:%02d:%02d%c%02d",
95 95
              hh, mm, ss, tc->drop ? ';' : ':', ff);
96 96
     return buf;
97 97
 }
... ...
@@ -67,8 +67,8 @@ uint32_t avpriv_framenum_to_smpte_timecode(unsigned frame, int fps, int drop);
67 67
  * @param tc    Timecode struct pointer
68 68
  * @param frame Frame id (timecode frame is computed with tc->start+frame)
69 69
  * @return a pointer to the buf parameter
70
- * @note  buf must have enough space to store the timecode representation
71
- *        (sizeof("hh:mm:ss.ff"))
70
+ * @note  buf must have enough space to store the timecode representation: 16
71
+ *        bytes is the minimum required size.
72 72
  */
73 73
 char *avpriv_timecode_to_string(char *buf, const struct ff_timecode *tc, unsigned frame);
74 74
 
... ...
@@ -731,7 +731,7 @@ static int draw_text(AVFilterContext *ctx, AVFilterBufferRef *picref,
731 731
 
732 732
 #if CONFIG_AVCODEC
733 733
     if (dtext->tc.str) {
734
-        char tcbuf[sizeof("hh:mm:ss.ff")];
734
+        char tcbuf[16];
735 735
         avpriv_timecode_to_string(tcbuf, &dtext->tc, dtext->frame_id++);
736 736
         buf = av_asprintf("%s%s", dtext->text, tcbuf);
737 737
     }