summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarsten Haitzler (Rasterman) <raster@rasterman.com>2018-11-08 17:11:07 +0000
committerCarsten Haitzler (Rasterman) <raster@rasterman.com>2018-11-09 12:18:59 +0000
commitb05472eb9d05ac659c1657eefabdfc1aeed4e3bb (patch)
tree3464575415f1d53a65281bbf3975f3c965d1c42d
parentb601e6f54b847a38b83b01e88d3149dff3ccbf15 (diff)
downloadefl-b05472eb9d05ac659c1657eefabdfc1aeed4e3bb.tar.gz
elm code - warn - explicit truncation via custom truncate func
-rw-r--r--src/lib/elementary/elm_code_widget_selection.c18
1 files changed, 16 insertions, 2 deletions
diff --git a/src/lib/elementary/elm_code_widget_selection.c b/src/lib/elementary/elm_code_widget_selection.c
index cf5f355009..31476ca4ad 100644
--- a/src/lib/elementary/elm_code_widget_selection.c
+++ b/src/lib/elementary/elm_code_widget_selection.c
@@ -203,6 +203,18 @@ _elm_code_widget_selection_delete_single(Elm_Code_Widget *widget, Elm_Code_Widge
}
static void
+my_string_copy_truncate(char *dest, const char *src, size_t len)
+{
+ char *p;
+ for (p = dest; len > 0; p++, src++, len--)
+ {
+ *p = *src;
+ if (*src == 0) break;
+ }
+}
+
+
+static void
_elm_code_widget_selection_delete_multi(Elm_Code_Widget *widget, Elm_Code_Widget_Data *pd)
{
Elm_Code_Line *line;
@@ -232,9 +244,11 @@ _elm_code_widget_selection_delete_multi(Elm_Code_Widget *widget, Elm_Code_Widget
if (last_length > 0)
{
if (end == last_length)
- strncpy(content + start, last + end, last_length - end);
+ my_string_copy_truncate(content + start, last + end,
+ last_length - end);
else
- strncpy(content + start, last + end + 1, last_length - (end + 1));
+ my_string_copy_truncate(content + start, last + end + 1,
+ last_length - (end + 1));
}
for (i = line->number; i > selection->start_line; i--)