From 70865d6c10bfd7f47ce26604bfb894ad67ebba36 Mon Sep 17 00:00:00 2001 From: Greg Ercolano Date: Mon, 6 Jan 2014 17:52:06 +0000 Subject: Fixes STR# 3025; string overflow with large filter()s. Replaced fixed arrays with dynamic strings. git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@10046 ea41ed52-d2ee-0310-a9c1-e6b18d33e121 --- src/Fl_Native_File_Chooser_common.cxx | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'src/Fl_Native_File_Chooser_common.cxx') diff --git a/src/Fl_Native_File_Chooser_common.cxx b/src/Fl_Native_File_Chooser_common.cxx index 7fec0a34e..1849ef50b 100644 --- a/src/Fl_Native_File_Chooser_common.cxx +++ b/src/Fl_Native_File_Chooser_common.cxx @@ -71,6 +71,26 @@ static void chrcat(char *s, char c) { strcat(s, tmp); } +// COUNT OCCURANCES OF CHAR 'c' IN 'find'. +int strcnt(const char *s, char c) { + int cnt = 0; + while ( *s ) { if (*s++ == c ) ++cnt; } + return cnt; +} + +// COUNT OCCURANCES OF ANY CHARS FROM 'find' IN 's'. +int strcnt(const char *s, const char *find) { + int cnt = 0; + const char *f; + while ( *s ) { + for (f=find; *f; f++) { + if (*s == *f) { ++cnt; break; } + } + ++s; + } + return cnt; +} + // // End of "$Id$". // -- cgit v1.2.3