diff options
| author | Greg Ercolano <erco@seriss.com> | 2024-04-04 10:03:35 -0700 |
|---|---|---|
| committer | Greg Ercolano <erco@seriss.com> | 2024-04-04 10:03:35 -0700 |
| commit | 06e495f26256a6d987f6d76cb291ba62fee85857 (patch) | |
| tree | 68a73a61a2dc5cbdfcaf92052b02ddd28af10bba /fluid/ExternalCodeEditor_UNIX.cxx | |
| parent | f779097c967f0224eac5bdd89df2a363c614fa91 (diff) | |
Add NULL check to UNIX save_file() (#945)
Diffstat (limited to 'fluid/ExternalCodeEditor_UNIX.cxx')
| -rw-r--r-- | fluid/ExternalCodeEditor_UNIX.cxx | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/fluid/ExternalCodeEditor_UNIX.cxx b/fluid/ExternalCodeEditor_UNIX.cxx index a04416034..4f0bea3f9 100644 --- a/fluid/ExternalCodeEditor_UNIX.cxx +++ b/fluid/ExternalCodeEditor_UNIX.cxx @@ -312,6 +312,7 @@ const char* ExternalCodeEditor::tmp_filename() { \return -1 on error (posts dialog with reason) */ static int save_file(const char *filename, const char *code) { + if ( code == 0 ) code = ""; // NULL? write an empty file int fd = open(filename, O_WRONLY|O_CREAT, 0666); if ( fd == -1 ) { fl_alert("ERROR: open() '%s': %s", filename, strerror(errno)); @@ -460,6 +461,7 @@ int ExternalCodeEditor::reap_editor(pid_t *pid_reaped) { Open external editor using 'editor_cmd' to edit 'code'. 'code' contains multiline code to be edited as a temp file. + 'code' can be NULL -- edits an empty file if so. \return 0 if succeeds \return -1 if can't open editor (already open, etc), |
