mirror of
https://github.com/fltk/fltk.git
synced 2026-06-01 06:14:28 +08:00
test/editor: ensure buffer termination
... in source file and documentation
This commit is contained in:
@@ -131,6 +131,7 @@ void update_title() {
|
|||||||
fname = fl_filename_name(app_filename);
|
fname = fl_filename_name(app_filename);
|
||||||
if (fname) {
|
if (fname) {
|
||||||
char buf[FL_PATH_MAX + 3];
|
char buf[FL_PATH_MAX + 3];
|
||||||
|
buf[FL_PATH_MAX + 2] = '\0'; // ensure that the buffer is always terminated
|
||||||
if (text_changed) {
|
if (text_changed) {
|
||||||
snprintf(buf, FL_PATH_MAX+2, "%s *", fname);
|
snprintf(buf, FL_PATH_MAX+2, "%s *", fname);
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
+2
-1
@@ -4,7 +4,7 @@
|
|||||||
// This program is described in chapter "Designing a Simple Text Editor"
|
// This program is described in chapter "Designing a Simple Text Editor"
|
||||||
// of the FLTK Programmer's Guide.
|
// of the FLTK Programmer's Guide.
|
||||||
//
|
//
|
||||||
// Copyright 1998-2024 by Bill Spitzak and others.
|
// Copyright 1998-2025 by Bill Spitzak and others.
|
||||||
//
|
//
|
||||||
// This library is free software. Distribution and use rights are outlined in
|
// This library is free software. Distribution and use rights are outlined in
|
||||||
// the file "COPYING" which should have been included with this file. If this
|
// the file "COPYING" which should have been included with this file. If this
|
||||||
@@ -61,6 +61,7 @@ void update_title() {
|
|||||||
fname = fl_filename_name(app_filename);
|
fname = fl_filename_name(app_filename);
|
||||||
if (fname) {
|
if (fname) {
|
||||||
char buf[FL_PATH_MAX + 3];
|
char buf[FL_PATH_MAX + 3];
|
||||||
|
buf[FL_PATH_MAX + 2] = '\0'; // ensure that the buffer is always terminated
|
||||||
if (text_changed) {
|
if (text_changed) {
|
||||||
snprintf(buf, FL_PATH_MAX+2, "%s *", fname);
|
snprintf(buf, FL_PATH_MAX+2, "%s *", fname);
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user