[vlc-commits] cdda: fix format-truncation warning

Thomas Guillem git at videolan.org
Wed Apr 14 10:52:45 UTC 2021


vlc | branch: master | Thomas Guillem <thomas at gllm.fr> | Wed Apr  7 14:49:06 2021 +0200| [5f24d66c06d6337eda485413bd6867d4572308fd] | committer: Thomas Guillem

cdda: fix format-truncation warning

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=5f24d66c06d6337eda485413bd6867d4572308fd
---

 modules/access/cdda.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/modules/access/cdda.c b/modules/access/cdda.c
index 9260b833ed..53a85a6f1a 100644
--- a/modules/access/cdda.c
+++ b/modules/access/cdda.c
@@ -639,8 +639,9 @@ static void AccessGetMeta(stream_t *access, vlc_meta_t *meta)
         {
             char yearbuf[5];
 
-            snprintf(yearbuf, sizeof (yearbuf), "%u", year);
-            vlc_meta_SetDate(meta, yearbuf);
+            int ret = snprintf(yearbuf, sizeof (yearbuf), "%u", year);
+            if (ret >= 0 && (size_t) ret < sizeof (yearbuf))
+                vlc_meta_SetDate(meta, yearbuf);
         }
 
         /* Set artist only if identical across tracks */



More information about the vlc-commits mailing list