From a32281c2684535b1f4de15fbcb353a773b713c66 Mon Sep 17 00:00:00 2001 From: Chow Loong Jin Date: Wed, 21 Mar 2018 15:38:33 +0800 Subject: [PATCH] Fix format-security violations (#802) croak() expects printf-style format strings. Calling croak(e.what()) directly causes compilations to fail with -Werror=format-security --- xs/xsp/GCode.xsp | 2 +- xs/xsp/PlaceholderParser.xsp | 4 ++-- xs/xsp/Print.xsp | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/xs/xsp/GCode.xsp b/xs/xsp/GCode.xsp index b4cb7c0e9..36b43271c 100644 --- a/xs/xsp/GCode.xsp +++ b/xs/xsp/GCode.xsp @@ -23,7 +23,7 @@ try { THIS->do_export(print, path); } catch (std::exception& e) { - croak(e.what()); + croak("%s\n", e.what()); } %}; void do_export_w_preview(Print *print, const char *path, GCodePreviewData *preview_data) diff --git a/xs/xsp/PlaceholderParser.xsp b/xs/xsp/PlaceholderParser.xsp index 244f89cf8..5fa4e33aa 100644 --- a/xs/xsp/PlaceholderParser.xsp +++ b/xs/xsp/PlaceholderParser.xsp @@ -18,7 +18,7 @@ try { RETVAL = THIS->process(str, 0); } catch (std::exception& e) { - croak(e.what()); + croak("%s\n", e.what()); } %}; @@ -27,7 +27,7 @@ try { RETVAL = THIS->evaluate_boolean_expression(str, THIS->config()); } catch (std::exception& e) { - croak(e.what()); + croak("%s\n", e.what()); } %}; }; diff --git a/xs/xsp/Print.xsp b/xs/xsp/Print.xsp index cbc04a804..ef9c5345f 100644 --- a/xs/xsp/Print.xsp +++ b/xs/xsp/Print.xsp @@ -212,7 +212,7 @@ _constant() try { RETVAL = THIS->output_filepath(path); } catch (std::exception& e) { - croak(e.what()); + croak("%s\n", e.what()); } %};