Skip to content

Commit 5a1892b

Browse files
committed
Fix minor stylistic/"analysis" nits
- Explicitly ignore strcpy_insitu return value in node_copy_string; if it fails, we must be out of memory and we leave the relevant destination fields empty, similarly to other OOMs during copying - Use the same code for eval_number of string/node set; these are slightly different semantically, as eval_string is an implicit conversion, but the code ends up the same. Closes #674, #675.
1 parent c4cca93 commit 5a1892b

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

src/pugixml.cpp

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4473,7 +4473,10 @@ PUGI_IMPL_NS_BEGIN
44734473
source_header |= xml_memory_page_contents_shared_mask;
44744474
}
44754475
else
4476-
strcpy_insitu(dest, header, header_mask, source, strlength(source));
4476+
{
4477+
// if strcpy_insitu fails (out of memory) we just leave the destination name/value empty
4478+
(void)strcpy_insitu(dest, header, header_mask, source, strlength(source));
4479+
}
44774480
}
44784481
}
44794482

@@ -11117,13 +11120,7 @@ PUGI_IMPL_NS_BEGIN
1111711120
return eval_boolean(c, stack) ? 1 : 0;
1111811121

1111911122
case xpath_type_string:
11120-
{
11121-
xpath_allocator_capture cr(stack.result);
11122-
11123-
return convert_string_to_number(eval_string(c, stack).c_str());
11124-
}
11125-
11126-
case xpath_type_node_set:
11123+
case xpath_type_node_set: // implicit conversion to string
1112711124
{
1112811125
xpath_allocator_capture cr(stack.result);
1112911126

0 commit comments

Comments
 (0)