diff options
author | Sebastian Berg <sebastian@sipsolutions.net> | 2020-06-16 16:34:58 -0500 |
---|---|---|
committer | Sebastian Berg <sebastian@sipsolutions.net> | 2020-06-16 20:48:44 -0500 |
commit | 1fab43749913aaa63168e4fdaaefffa67e9da36f (patch) | |
tree | 96d6783f8c8897d3621e4c1c2392240f9d6ff23c | |
parent | 1fb7047b0ceba98d43b50ebb398be899ff8f6a1c (diff) | |
download | numpy-1fab43749913aaa63168e4fdaaefffa67e9da36f.tar.gz |
BUG: Initialize stop-reading in array_from_text
This should probably be hit with count=0, which is why added
a test which takes that path. However, I was not actually
able to trigger any issue (not even a warning in valgrind).
I assume that since this is on the stack, its just hard to
trigger.
This came up in another CI-run. I suppose gcc as well as clang seem
to notice that it can be used uninitialized (which is true).
-rw-r--r-- | numpy/core/src/multiarray/ctors.c | 2 | ||||
-rw-r--r-- | numpy/core/tests/test_multiarray.py | 4 |
2 files changed, 5 insertions, 1 deletions
diff --git a/numpy/core/src/multiarray/ctors.c b/numpy/core/src/multiarray/ctors.c index 3c3bcb387..c7d149577 100644 --- a/numpy/core/src/multiarray/ctors.c +++ b/numpy/core/src/multiarray/ctors.c @@ -3580,7 +3580,7 @@ array_from_text(PyArray_Descr *dtype, npy_intp num, char const *sep, size_t *nre npy_intp i; char *dptr, *clean_sep, *tmp; int err = 0; - int stop_reading_flag; /* -1 indicates end reached; -2 a parsing error */ + int stop_reading_flag = 0; /* -1 means end reached; -2 a parsing error */ npy_intp thisbuf = 0; npy_intp size; npy_intp bytes, totalbytes; diff --git a/numpy/core/tests/test_multiarray.py b/numpy/core/tests/test_multiarray.py index e116077f9..09adddf6d 100644 --- a/numpy/core/tests/test_multiarray.py +++ b/numpy/core/tests/test_multiarray.py @@ -4702,6 +4702,10 @@ class TestIO: e = np.array([-25041670086757, 104783749223640], dtype=np.int64) assert_array_equal(d, e) + def test_fromstring_count0(self): + d = np.fromstring("1,2", sep=",", dtype=np.int64, count=0) + assert d.shape == (0,) + def test_empty_files_binary(self): with open(self.filename, 'w') as f: pass |