aboutsummaryrefslogtreecommitdiffhomepage
path: root/gtk/PlatGTK.cxx
diff options
context:
space:
mode:
authorNeil <nyamatongwe@gmail.com>2013-12-22 18:00:45 +1100
committerNeil <nyamatongwe@gmail.com>2013-12-22 18:00:45 +1100
commitdac5800933977672e8d2d67854a97a517abbe47d (patch)
treec057a54cf4b5f01be58cc5042ee30043a2363ba6 /gtk/PlatGTK.cxx
parent3f4549e26cb8182fa236ea3c8a08c20a71e4da38 (diff)
downloadscintilla-mirror-dac5800933977672e8d2d67854a97a517abbe47d.tar.gz
Avoid unsafe strcpy, strncpy, and strcat replacing with safer functions which
guaranty termination where possible.
Diffstat (limited to 'gtk/PlatGTK.cxx')
-rw-r--r--gtk/PlatGTK.cxx11
1 files changed, 5 insertions, 6 deletions
diff --git a/gtk/PlatGTK.cxx b/gtk/PlatGTK.cxx
index da9171470..1479d50ee 100644
--- a/gtk/PlatGTK.cxx
+++ b/gtk/PlatGTK.cxx
@@ -23,8 +23,9 @@
#include "Scintilla.h"
#include "ScintillaWidget.h"
-#include "UniConversion.h"
+#include "StringCopy.h"
#include "XPM.h"
+#include "UniConversion.h"
#if defined(__clang__)
// Clang 3.0 incorrectly displays sentinel warnings. Fixed by clang 3.1.
@@ -231,7 +232,7 @@ static void SetLogFont(LOGFONT &lf, const char *faceName, int characterSet, floa
lf.weight = weight;
lf.italic = italic;
lf.characterSet = characterSet;
- strncpy(lf.faceName, faceName, sizeof(lf.faceName) - 1);
+ StringCopy(lf.faceName, faceName);
}
/**
@@ -1830,8 +1831,7 @@ void ListBoxX::GetValue(int n, char *value, int len) {
gtk_tree_model_get(model, &iter, TEXT_COLUMN, &text, -1);
}
if (text && len > 0) {
- strncpy(value, text, len);
- value[len - 1] = '\0';
+ g_strlcpy(value, text, len);
} else {
value[0] = '\0';
}
@@ -2142,8 +2142,7 @@ bool Platform::ShowAssertionPopUps(bool assertionPopUps_) {
void Platform::Assert(const char *c, const char *file, int line) {
char buffer[2000];
- sprintf(buffer, "Assertion [%s] failed at %s %d", c, file, line);
- strcat(buffer, "\r\n");
+ g_snprintf(buffer, sizeof(buffer), "Assertion [%s] failed at %s %d\r\n", c, file, line);
Platform::DebugDisplay(buffer);
abort();
}