mirror of
https://github.com/python/cpython.git
synced 2025-09-26 18:29:57 +00:00
_testbuffer.c: In all current use cases of cmp_structure() dest->format and
src->format are either both NULL or both non-NULL. However, it is safer to generalize the function. Found by Coverity.
This commit is contained in:
parent
b2a61e1ead
commit
527a2400fb
1 changed files with 2 additions and 3 deletions
|
@ -16,6 +16,7 @@ PyObject *calcsize = NULL;
|
||||||
static const char *simple_fmt = "B";
|
static const char *simple_fmt = "B";
|
||||||
PyObject *simple_format = NULL;
|
PyObject *simple_format = NULL;
|
||||||
#define SIMPLE_FORMAT(fmt) (fmt == NULL || strcmp(fmt, "B") == 0)
|
#define SIMPLE_FORMAT(fmt) (fmt == NULL || strcmp(fmt, "B") == 0)
|
||||||
|
#define FIX_FORMAT(fmt) (fmt == NULL ? "B" : fmt)
|
||||||
|
|
||||||
|
|
||||||
/**************************************************************************/
|
/**************************************************************************/
|
||||||
|
@ -513,10 +514,8 @@ static int
|
||||||
cmp_structure(Py_buffer *dest, Py_buffer *src)
|
cmp_structure(Py_buffer *dest, Py_buffer *src)
|
||||||
{
|
{
|
||||||
Py_ssize_t i;
|
Py_ssize_t i;
|
||||||
int same_fmt = ((dest->format == NULL && src->format == NULL) || \
|
|
||||||
(strcmp(dest->format, src->format) == 0));
|
|
||||||
|
|
||||||
if (!same_fmt ||
|
if (strcmp(FIX_FORMAT(dest->format), FIX_FORMAT(src->format)) != 0 ||
|
||||||
dest->itemsize != src->itemsize ||
|
dest->itemsize != src->itemsize ||
|
||||||
dest->ndim != src->ndim)
|
dest->ndim != src->ndim)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue