summaryrefslogtreecommitdiff
path: root/numpy/core
diff options
context:
space:
mode:
authorCharles Harris <charlesr.harris@gmail.com>2022-06-08 14:01:51 -0600
committerGitHub <noreply@github.com>2022-06-08 14:01:51 -0600
commit11cc8a2476df22b9998bc90b56048c81b943cca0 (patch)
treeb5e239cfcb627a0082d30248d28b065fcc09dc85 /numpy/core
parente05e65718b34aea0c3be393459e2d5933ab075e0 (diff)
parent6cd2148457b8d1582b731d06af3092caa65678d3 (diff)
downloadnumpy-11cc8a2476df22b9998bc90b56048c81b943cca0.tar.gz
Merge pull request #21691 from seberg/valgrind-fixes
BUG: Small fixupes found using valgrind
Diffstat (limited to 'numpy/core')
-rw-r--r--numpy/core/src/multiarray/convert_datatype.c3
-rw-r--r--numpy/core/src/multiarray/textreading/tokenize.cpp5
2 files changed, 6 insertions, 2 deletions
diff --git a/numpy/core/src/multiarray/convert_datatype.c b/numpy/core/src/multiarray/convert_datatype.c
index 79f918d2a..8d0a4cd56 100644
--- a/numpy/core/src/multiarray/convert_datatype.c
+++ b/numpy/core/src/multiarray/convert_datatype.c
@@ -3403,6 +3403,9 @@ void_to_void_resolve_descriptors(
/* From structured to structured, need to check fields */
casting = can_cast_fields_safety(
given_descrs[0], given_descrs[1], view_offset);
+ if (casting < 0) {
+ return -1;
+ }
}
else if (given_descrs[0]->names != NULL) {
return structured_to_nonstructured_resolve_descriptors(
diff --git a/numpy/core/src/multiarray/textreading/tokenize.cpp b/numpy/core/src/multiarray/textreading/tokenize.cpp
index b09fc3356..d0d9cf844 100644
--- a/numpy/core/src/multiarray/textreading/tokenize.cpp
+++ b/numpy/core/src/multiarray/textreading/tokenize.cpp
@@ -386,9 +386,10 @@ tokenize(stream *s, tokenizer_state *ts, parser_config *const config)
* empty.
* 2. If we are splitting on whitespace we always ignore a last empty
* field to match Python's splitting: `" 1 ".split()`.
+ * (Zero fields are possible when we are only skipping lines)
*/
- if (ts->num_fields == 1
- || ts->unquoted_state == TOKENIZE_UNQUOTED_WHITESPACE) {
+ if (ts->num_fields == 1 || (ts->num_fields > 0
+ && ts->unquoted_state == TOKENIZE_UNQUOTED_WHITESPACE)) {
size_t offset_last = ts->fields[ts->num_fields-1].offset;
size_t end_last = ts->fields[ts->num_fields].offset;
if (!ts->fields->quoted && end_last - offset_last == 1) {