summaryrefslogtreecommitdiff
path: root/Lib/octave
diff options
context:
space:
mode:
authorOlly Betts <olly@survex.com>2023-04-23 12:10:21 +1200
committerOlly Betts <olly@survex.com>2023-04-27 10:08:57 +1200
commit1f5ff2e6a585d0b5dca501945fabfeb48b1bf547 (patch)
tree8e89ad3733384a7dc952b74a8243562bee3cb85e /Lib/octave
parent589373309dae750ed05a46b1b955993da253a287 (diff)
downloadswig-1f5ff2e6a585d0b5dca501945fabfeb48b1bf547.tar.gz
Allow using snprintf() instead of sprintf() in wrappers
We aim to produce code that works with C90 or C++98 so we can't assume snprintf() is available, but it almost always is (even on systems from before it was standardised) so having a way to use it is helpful. Enable this automatically if the compiler claims conformance with at least C90 or C++98 and check SWIG_HAVE_SNPRINTF to allow turning on manually, but disable if SWIG_NO_SNPRINTF if defined. The fallback is to call sprintf() without a buffer size check - checking after the call is really shutting the stable door after the horse has bolted, and most of our uses either have a fixed maximum possible size or dynamically allocate a buffer that's large enough. Fixes: #2502 (sprintf deprecation warnings on macos) Fixes: #2548
Diffstat (limited to 'Lib/octave')
-rw-r--r--Lib/octave/octcontainer.swg2
1 files changed, 1 insertions, 1 deletions
diff --git a/Lib/octave/octcontainer.swg b/Lib/octave/octcontainer.swg
index 394c90bac..5031e703f 100644
--- a/Lib/octave/octcontainer.swg
+++ b/Lib/octave/octcontainer.swg
@@ -198,7 +198,7 @@ namespace swig
return swig::as<T>(item);
} catch (const std::exception& e) {
char msg[1024];
- sprintf(msg, "in sequence element %d ", _index);
+ SWIG_snprintf(msg, sizeof(msg), "in sequence element %d ", _index);
if (!Octave_Error_Occurred()) {
%type_error(swig::type_name<T>());
}