summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorL. E. Segovia <amy@centricular.com>2024-07-09 12:03:53 -0300
committerTim-Philipp Müller <tim@centricular.com>2024-07-19 11:38:59 +0100
commitabd75edff9de9a06d0531b9db50963a0da42145c (patch)
treeae012a86a086f262d7e7c1d7f183e402fe02f505
parentfb7db9ae3e8ac271651d1884a3611d30bac04a98 (diff)
orccompiler, orcparse: Use secure UCRT printing functions on Windows
See #69 Part-of: <https://gitlab.freedesktop.org/gstreamer/orc/-/merge_requests/191>
-rw-r--r--orc/orccompiler.c5
-rw-r--r--orc/orcparse.c5
2 files changed, 8 insertions, 2 deletions
diff --git a/orc/orccompiler.c b/orc/orccompiler.c
index d339461..617ae29 100644
--- a/orc/orccompiler.c
+++ b/orc/orccompiler.c
@@ -1485,12 +1485,15 @@ static void
orc_compiler_error_valist (OrcCompiler *compiler, const char *fmt,
va_list args)
{
- char *s;
+ char *s = NULL;
if (compiler->error_msg) return;
#ifdef HAVE_VASPRINTF
vasprintf (&s, fmt, args);
+#elif defined(_UCRT)
+ s = malloc (ORC_COMPILER_ERROR_BUFFER_SIZE);
+ vsnprintf_s (s, ORC_COMPILER_ERROR_BUFFER_SIZE, _TRUNCATE, fmt, args);
#else
s = malloc (ORC_COMPILER_ERROR_BUFFER_SIZE);
vsnprintf (s, ORC_COMPILER_ERROR_BUFFER_SIZE, fmt, args);
diff --git a/orc/orcparse.c b/orc/orcparse.c
index ae4f1b6..abeb9f5 100644
--- a/orc/orcparse.c
+++ b/orc/orcparse.c
@@ -429,8 +429,11 @@ orc_parse_add_error_valist (OrcParser *parser, const char *format, va_list args)
}
#ifdef HAVE_VASPRINTF
- char *text;
+ char *text = NULL;
vasprintf (&text, format, args);
+#elif defined(_UCRT)
+ char text[ORC_ERROR_LENGTH] = { '\0' };
+ vsnprintf_s (text, ORC_ERROR_LENGTH, _TRUNCATE, format, args);
#else
char text[ORC_ERROR_LENGTH] = { '\0' };
vsnprintf (text, sizeof (text), format, args);