VLA in _gnutls_dump_vector()
Compiling the debug.c
file with cl -c -DDEBUG ...
(with MSVC-2019), yields this error:
debug.c(47): error C2057: expected constant expression
debug.c(47): error C2466: cannot allocate an array of constant size 0
debug.c(47): error C2133: 'buf_hex': unknown size
debug.c(51): warning C4034: sizeof returns 0
Wouldn't it be better by using alloca()
for MSVC in this case:
--- a/lib/debug.c 2022-03-13 16:34:15
+++ b/lib/debug.c 2022-03-14 11:28:50
@@ -44,7 +44,11 @@
void
_gnutls_dump_vector(const char *prefix, const uint8_t * a, size_t a_size)
{
- char buf_hex[2 * a_size + 1];
+#ifdef _MSC_VER
+ char *buf_hex = alloca (2 * a_size + 1);
+#else
+ char *buf_hex[2 * a_size + 1];
+#endif
But I cannot see this functions is called anywhere. So why is it there?
I made a similar issue 4 years ago. And I'm amazed MSVC is still not fully supported.