blob: c918da44b40a202aafc4f65196e169bfaf7f2275 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
$NetBSD: patch-ae,v 1.2 2010/08/11 12:21:56 dsainty Exp $
Don't unnecessarily remove const, which complicates casting.
Correctly terminate default string values on NUL.
--- libflatfile/DB.cpp.orig 2003-06-20 11:37:46.000000000 +1200
+++ libflatfile/DB.cpp 2010-08-08 23:26:16.387306351 +1200
@@ -221,7 +221,7 @@
throw PalmLib::error("list view is corrupt");
// Determine the length of the name string.
- pi_char_t* null_ptr = reinterpret_cast<pi_char_t*>
+ const pi_char_t* null_ptr = reinterpret_cast<const pi_char_t*>
(memchr(chunk.data() + 4, 0, 32));
if (null_ptr)
lv.name = std::string((char *) (chunk.data() + 4),
@@ -275,7 +275,8 @@
switch (type) {
case PalmLib::FlatFile::Field::STRING:
- theReturn << std::string((const char *)chunk.data()+2, chunk.size() - 2);
+ // c_str: The default value is (or at least may be) NUL terminated.
+ theReturn << std::string((const char *)chunk.data()+2, chunk.size() - 2).c_str();
break;
case PalmLib::FlatFile::Field::BOOLEAN:
|