summaryrefslogtreecommitdiff
path: root/fluid/ExternalCodeEditor_UNIX.cxx
diff options
context:
space:
mode:
authorAlbrecht Schlosser <albrechts.fltk@online.de>2020-06-24 20:20:11 +0200
committerAlbrecht Schlosser <albrechts.fltk@online.de>2020-06-24 20:20:11 +0200
commit1da349579dcdf0b616cb3ea00a5ee3a60a86bc25 (patch)
tree88296652055d9631125e3446251de105fd30e76a /fluid/ExternalCodeEditor_UNIX.cxx
parent4c9b44f01ef0e3e3c66add6e5ada45242c25a6fe (diff)
Fix static code analyzer warnings
Note: there's more to do ...
Diffstat (limited to 'fluid/ExternalCodeEditor_UNIX.cxx')
-rw-r--r--fluid/ExternalCodeEditor_UNIX.cxx12
1 files changed, 9 insertions, 3 deletions
diff --git a/fluid/ExternalCodeEditor_UNIX.cxx b/fluid/ExternalCodeEditor_UNIX.cxx
index ccc265ff1..8e415e0b3 100644
--- a/fluid/ExternalCodeEditor_UNIX.cxx
+++ b/fluid/ExternalCodeEditor_UNIX.cxx
@@ -296,6 +296,9 @@ static int save_file(const char *filename, const char *code) {
// o 's' will be modified (words will be NULL separated)
// o argv[] will end up pointing to the words of 's'
// o Caller must free argv with: free(argv);
+// Returns:
+// o -1 in case of memory allocation error
+// o number of arguments in argv (same value as in argc)
//
static int make_args(char *s, // string containing words (gets trashed!)
int *aargc, // pointer to argc
@@ -334,10 +337,13 @@ int ExternalCodeEditor::start_editor(const char *editor_cmd,
// NOTE: OSX wants minimal code between fork/exec, see Apple TN2083
int nargs;
char **args = 0;
- make_args(cmd, &nargs, &args);
- execvp(args[0], args); // run command - doesn't return if succeeds
- fl_alert("couldn't exec() '%s': %s", cmd, strerror(errno));
+ if (make_args(cmd, &nargs, &args) > 0) {
+ execvp(args[0], args); // run command - doesn't return if succeeds
+ fl_alert("couldn't exec() '%s': %s", cmd, strerror(errno));
+ exit(1);
+ }
exit(1);
+ // break;
}
default: // parent
if ( L_editors_open++ == 0 ) // first editor? start timers