summaryrefslogtreecommitdiff
path: root/libs/ardour/recent_sessions.cc
diff options
context:
space:
mode:
authorRobin Gareus <robin@gareus.org>2015-09-10 17:34:59 +0200
committerRobin Gareus <robin@gareus.org>2015-09-10 17:39:31 +0200
commit8d54a2472dcb8ebe83da5db7436b4bfdeb9a00c2 (patch)
tree306120a4543794fcfb4f5b43619d2ca9d5fac130 /libs/ardour/recent_sessions.cc
parentb7fbd4e9c0a1c2ec13f70183cfaaa7ce13e231e8 (diff)
fix recent session loading.
std::stringstream::operator<< calls strlen(), but the string in the temp buffer may not [yet] be NULL terminated.
Diffstat (limited to 'libs/ardour/recent_sessions.cc')
-rw-r--r--libs/ardour/recent_sessions.cc23
1 files changed, 9 insertions, 14 deletions
diff --git a/libs/ardour/recent_sessions.cc b/libs/ardour/recent_sessions.cc
index 85c3c55f16..f19c0d8d37 100644
--- a/libs/ardour/recent_sessions.cc
+++ b/libs/ardour/recent_sessions.cc
@@ -61,27 +61,22 @@ ARDOUR::read_recent_sessions (RecentSessions& rs)
}
}
-
-
- // Read the file into a std::string;
+ // Read the file into a std::string
std::stringstream recent;
- char temporaryBuffer[1024];
- while (!feof(fin))
- {
- size_t charsRead = fread(&temporaryBuffer[0], sizeof(char), 1024, fin);
- if (charsRead != 1024 && ferror(fin))
- {
+ while (!feof (fin)) {
+ char buf[1024];
+ size_t charsRead = fread (buf, sizeof(char), 1024, fin);
+ if (ferror (fin)) {
error << string_compose (_("Error reading recent session file %1 (%2)"), path, strerror (errno)) << endmsg;
fclose(fin);
return -1;
}
- recent << &temporaryBuffer[0];
+ if (charsRead == 0) {
+ break;
+ }
+ recent.write (buf, charsRead);
}
-
-
- //ifstream recent (fin);
-
while (true) {
pair<string,string> newpair;