segfault from strcat

hi everyone,
i'm working with lua, and when i want to load a script, using TinyFileDialogs, i get this segfault
this is very anoying for me, please show me what is wrong!
[code]
Building to ensure sources are up-to-date
Selecting target:
Debug
Adding source dir: F:\projects\cpp\mge\
Adding source dir: F:\projects\cpp\mge\
Adding file: F:\projects\cpp\mge\bin\Debug\aage.exe
Changing directory to: F:/projects/cpp/ADVANC~1/.
Set variable: PATH=.;C:\Dev-Cpp\bin;C:\Dev-Cpp\bin\bin;C:\Perl\site\bin;C:\Perl\bin;C:\Python27;C:\Python27\Scripts;C:\Windows\System32;C:\Windows;C:\Windows\System32\wbem;C:\Windows\System32\WindowsPowerShell\v1.0;C:\Program Files\CMake 2.8\bin;C:\Program Files\WinSCP;C:\Program Files\TortoiseSVN\bin;C:\Program Files\Skype\Phone;C:\Program Files\nmap

[debug]Command-line: gdb.exe -nx -fullname -quiet -args F:/projects/cpp/ADVANC~1/bin/Debug/aage.exe
[debug]Working dir : F:\projects\cpp\ADVANC~1

Starting debugger: gdb.exe -nx -fullname -quiet -args F:/projects/cpp/ADVANC~1/bin/Debug/aage.exe
done

[debug]> set prompt >>>>>>cb_gdb:

Registered new type: wxString
Registered new type: STL String
Registered new type: STL Vector
Setting breakpoints

[debug]Reading symbols from F:\projects\cpp\ADVANC~1\bin\Debug\aage.exe...
[debug]done.
[debug](gdb) >>>>>>cb_gdb:
[debug]> show version
[debug]GNU gdb (GDB) 7.6.1
[debug]Copyright (C) 2013 Free Software Foundation, Inc.
[debug]License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
[debug]This is free software: you are free to change and redistribute it.
[debug]There is NO WARRANTY, to the extent permitted by law. Type "show copying"
[debug]and "show warranty" for details.
[debug]This GDB was configured as "mingw32".
[debug]For bug reporting instructions, please see:
[debug]<http://www.gnu.org/software/gdb/bugs/>.
[debug]>>>>>>cb_gdb:
[debug]> set confirm off

Debugger name and version: GNU gdb (GDB) 7.6.1

[debug]>>>>>>cb_gdb:
[debug]> set width 0
[debug]>>>>>>cb_gdb:
[debug]> set height 0
[debug]>>>>>>cb_gdb:
[debug]> set breakpoint pending on
[debug]>>>>>>cb_gdb:
[debug]> set print asm-demangle on
[debug]>>>>>>cb_gdb:
[debug]> set unwindonsignal on
[debug]>>>>>>cb_gdb:
[debug]> set print elements 0
[debug]>>>>>>cb_gdb:
[debug]> set new-console on
[debug]>>>>>>cb_gdb:
[debug]> set disassembly-flavor att
[debug]>>>>>>cb_gdb:
[debug]> catch throw
[debug]Catchpoint 1 (throw)
[debug]>>>>>>cb_gdb:
[debug]> source C:\Program Files\CodeBlocks\share\codeblocks/scripts/stl-views-1.0.3.gdb
[debug]>>>>>>cb_gdb:
[debug]> directory F:/projects/cpp/ADVANC~1/
[debug]Source directories searched: F:/projects/cpp/ADVANC~1;$cdir;$cwd
[debug]>>>>>>cb_gdb:
[debug]> run
[debug]Starting program: F:/projects/cpp/ADVANC~1/bin/Debug/aage.exe

Child process PID: 8656

[debug][New Thread 8656.0x2010]
[debug][New Thread 8656.0x221c]
[debug][New Thread 8656.0x2080]
[debug][New Thread 8656.0x2170]
[debug]Program received signal SIGSEGV, Segmentation fault.
[debug]0x75258e17 in strcat () from C:\Windows\system32\msvcrt.dll
[debug]>>>>>>cb_gdb:

Program received signal SIGSEGV, Segmentation fault.
In strcat () (C:\Windows\system32\msvcrt.dll)

[debug]> bt 30
[debug]#0 0x75258e17 in strcat () from C:\Windows\system32\msvcrt.dll
[debug]#1 0x0022f830 in ?? ()
[debug]#2 0x0040d669 in tinyfd_openFileDialog (aTitle=0x567741 <std::ignore+383> "select which script to load", aDefaultPathAndFile=0x567717 <std::ignore+341> "", aNumOfFileFilters=1, aFileFilters=0x567718 <std::ignore+342>, aAllowMultipleSelects=0) at F:\projects\cpp\mge\src\tinyfiledialogs.c:1522
[debug]#3 0x0040674d in main (argc=1, argv=0xa013e8) at F:\projects\cpp\mge\src\main.cpp:195
[debug]>>>>>>cb_gdb:
[debug]> frame 2
[debug]#2 0x0040d669 in tinyfd_openFileDialog (aTitle=0x567741 <std::ignore+383> "select which script to load", aDefaultPathAndFile=0x567717 <std::ignore+341> "", aNumOfFileFilters=1, aFileFilters=0x567718 <std::ignore+342>, aAllowMultipleSelects=0) at F:\projects\cpp\mge\src\tinyfiledialogs.c:1522
[debug]

F:\projects\cpp\mge\src\tinyfiledialogs.c:1522:38783:beg:0x40d669
[debug]>>>>>>cb_gdb:

#2 0x0040d669 in tinyfd_openFileDialog (aTitle=0x567741 <std::ignore+383> "select which script to load", aDefaultPathAndFile=0x567717 <std::ignore+341> "", aNumOfFileFilters=1, aFileFilters=0x567718 <std::ignore+342>, aAllowMultipleSelects=0) at F:\projects\cpp\mge\src\tinyfiledialogs.c:1522


F:\projects\cpp\mge\src\tinyfiledialogs.c:1522:38783:beg:0x40d669
At F:\projects\cpp\mge\src\tinyfiledialogs.c:1522

[debug]> bt 30
[debug]#0 0x75258e17 in strcat () from C:\Windows\system32\msvcrt.dll
[debug]#1 0x0022f830 in ?? ()
[debug]#2 0x0040d669 in tinyfd_openFileDialog (aTitle=0x567741 <std::ignore+383> "select which script to load", aDefaultPathAndFile=0x567717 <std::ignore+341> "", aNumOfFileFilters=1, aFileFilters=0x567718 <std::ignore+342>, aAllowMultipleSelects=0) at F:\projects\cpp\mge\src\tinyfiledialogs.c:1522
[debug]#3 0x0040674d in main (argc=1, argv=0xa013e8) at F:\projects\cpp\mge\src\main.cpp:195
[debug]>>>>>>cb_gdb:
[debug]> frame 2
[debug]#2 0x0040d669 in tinyfd_openFileDialog (aTitle=0x567741 <std::ignore+383> "select which script to load", aDefaultPathAndFile=0x567717 <std::ignore+341> "", aNumOfFileFilters=1, aFileFilters=0x567718 <std::ignore+342>, aAllowMultipleSelects=0) at F:\projects\cpp\mge\src\tinyfiledialogs.c:1522
[debug]

F:\projects\cpp\mge\src\tinyfiledialogs.c:1522:38783:beg:0x40d669
[debug]>>>>>>cb_gdb:

#2 0x0040d669 in tinyfd_openFileDialog (aTitle=0x567741 <std::ignore+383> "select which script to load", aDefaultPathAndFile=0x567717 <std::ignore+341> "", aNumOfFileFilters=1, aFileFilters=0x567718 <std::ignore+342>, aAllowMultipleSelects=0) at F:\projects\cpp\mge\src\tinyfiledialogs.c:1522


F:\projects\cpp\mge\src\tinyfiledialogs.c:1522:38783:beg:0x40d669
[/CODE]
the code that crashe's is:
 
scriptfile=tinyfd_openFileDialog("select which script to load", "", 1, (const char* const*) "script files (*.mge;*.lua)\0*.mge;*.lua", false);

please tell me what is wrong in it!
note that i cant publish all the codes here
Last edited on
I'm not familiar with tinyfd, but the fourth parameter doesn't look right. From the sourceforge page char const * const * const aFileFilters , // NULL or {"*.jpg","*.png"} so you might want to try passing {"*.mge","*.lua"} as the fourth parameter.
so, if i want to write a discription like script files(*.mge,*.lua), what i have to do?
thanks again
Maybe add it to the title.
if i add it to title, it show's that discription on the title bar of the window!, but i want to show it to the file Type list!
fixed
i found how to do that!
1
2
3
const char* title[] = {
"script files (*.mge;*.lua)\0*.mge;*.lua"
};

the problem was that i didnt declared an array of char*, and i've got segfaults
now, if you want to have more filters, add it in the array like above, and set the filter to the array length
for example if you have 3 types of filters, you need to set the filter number to 3, and in your array, code them like above as an entry
thanks all for your suggestions
hi, I am the author of tinyfiledialogs,

the filter only accept this kind of arrays:

char const * fileFilters [ ] = { "*.mge" , "*.lua" } ;

you are not suppose to pass any text for the user (the "script files .." part)

so, if user want's to have a discription, in his or her dialog what he or she has to do?
and, in my idea, all files should not be at the end of discription, the user should specify it
thanks for your reply
I didn't think it was important, so I didn't implement it. Obviously I was wrong, I will try to add it in a near futur.
it is very important to some programmers!
and, all files has a description, but other file types have not descriptions!
I've just released a new version (v2.2) including the filter description. Give it a try.
Last edited on
Topic archived. No new replies allowed.