Skip to content

Commit

Permalink
Fixed crash in Fl_Preferences if 2nd or 3rd argument in the 'path' co…
Browse files Browse the repository at this point in the history
…nstructor were NULL

git-svn-id: file:///fltk/svn/fltk/branches/branch-1.1@5007 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
  • Loading branch information
Matthias Melcher committed Apr 20, 2006
1 parent a82e787 commit 0b98e81
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 15 deletions.
5 changes: 1 addition & 4 deletions CHANGES
@@ -1,9 +1,6 @@
CHANGES IN FLTK 1.1.9

- caret key lookup was missing for OS X

CHANGES IN FLTK 1.1.8

- caret key lookup was missing for OS X
- FLUID didn't handle loading .fl files with
international characters properly with all compilers
(STR #1150)
Expand Down
20 changes: 14 additions & 6 deletions documentation/Fl_Preferences.html
Expand Up @@ -69,9 +69,11 @@ <h3>Methods</h3>

</ul>

<H4><a name="Fl_Preferences.Fl_Preferences">Fl_Preferences(enum Root root,
const char *vendor, const char *application)<BR>
Fl_Preferences(Fl_Preferences &amp;p, const char *groupname)</a></H4>
<H4><a name="Fl_Preferences.Fl_Preferences">
Fl_Preferences(enum Root root, const char *vendor, const char *application)<BR>
Fl_Preferences(const char *path, const char *vendor, const char *application)<BR>
Fl_Preferences(Fl_Preferences &amp;p, const char *groupname)<BR>
</a></H4>

<P>The constructor creates a group that manages name/value pairs and
child groups. Groups are ready for reading and writing at any time.
Expand All @@ -89,9 +91,15 @@ <H4><a name="Fl_Preferences.Fl_Preferences">Fl_Preferences(enum Root root,
<tt>application</tt> must be valid relative UNIX pathnames and
may contain '/'s to create deeper file structures.

<P>The <tt>groupname</tt> argument identifies a group of
entries. It can contain '/'s to get quick access to individual
elements inside the hierarchy.
<P>The second format is used to create a preferences file at an
arbitrary position in the file system. The file name is generated
as <tt><i>path</i>/<i>application</i>.prefs</tt>. If <i>application</i>
is 0, <i>path</i> must contain the full file name.

<P>The third format generates a new group of preference entries
inside the group or file <i>p</i>. The <tt>groupname</tt> argument
identifies a group of entries. It can contain '/'s to get quick
access to individual elements inside the hierarchy.

<H4><a name="Fl_Preferences.~Fl_Preferences">~Fl_Preferences()</a></H4>

Expand Down
15 changes: 10 additions & 5 deletions src/Fl_Preferences.cxx
Expand Up @@ -693,12 +693,17 @@ Fl_Preferences::RootNode::RootNode( Fl_Preferences *prefs, Root root, const char
// - construct the name of the file that will hold our preferences
Fl_Preferences::RootNode::RootNode( Fl_Preferences *prefs, const char *path, const char *vendor, const char *application )
{
char filename[ FL_PATH_MAX ]; filename[0] = 0;

snprintf(filename, sizeof(filename), "%s/%s.prefs", path, application);

if (!vendor)
vendor = "unknown";
if (!application) {
application = "unknown";
filename_ = strdup(path);
} else {
char filename[ FL_PATH_MAX ]; filename[0] = 0;
snprintf(filename, sizeof(filename), "%s/%s.prefs", path, application);
filename_ = strdup(filename);
}
prefs_ = prefs;
filename_ = strdup(filename);
vendor_ = strdup(vendor);
application_ = strdup(application);

Expand Down

0 comments on commit 0b98e81

Please sign in to comment.