Move zero-termination out of as_utf8_end
as_utf8_end was used with std::string, where writing an extra zero-terminating character should *probably* always work (at least if size is positive) but is not ideal. The only place that needed to zero-terminate was convert_path_heap.
This commit is contained in:
parent
3da7d68617
commit
99afee1832
@ -1691,9 +1691,6 @@ PUGI__NS_BEGIN
|
|||||||
|
|
||||||
assert(begin + size == end);
|
assert(begin + size == end);
|
||||||
(void)!end;
|
(void)!end;
|
||||||
|
|
||||||
// zero-terminate
|
|
||||||
buffer[size] = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef PUGIXML_NO_STL
|
#ifndef PUGIXML_NO_STL
|
||||||
@ -4295,6 +4292,9 @@ PUGI__NS_BEGIN
|
|||||||
// second pass: convert to utf8
|
// second pass: convert to utf8
|
||||||
as_utf8_end(result, size, str, length);
|
as_utf8_end(result, size, str, length);
|
||||||
|
|
||||||
|
// zero-terminate
|
||||||
|
result[size] = 0;
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user