File: | _imaging.c |
Function: | _histogram |
Error: | calling PyList_SetItem with NULL as argument 1 (list) at _imaging.c:1045 |
981 static PyObject*
982 _histogram(ImagingObject* self, PyObject* args)
983 {
984 ImagingHistogram h;
985 PyObject* list;
986 int i;
987 union {
988 UINT8 u[2];
989 INT32 i[2];
990 FLOAT32 f[2];
991 } extrema;
992 void* ep;
993 int i0, i1;
994 double f0, f1;
995
996 PyObject* extremap = NULL;
997 ImagingObject* maskp = NULL;
998 if (!PyArg_ParseTuple(args, "|OO!", &extremap, &Imaging_Type, &maskp))
when PyArg_ParseTuple() succeeds
taking False path
999 return NULL;
1000
1001 if (extremap) {
taking True path
1002 ep = &extrema;
1003 switch (self->image->type) {
when treating unknown struct ImagingMemoryInstance * from _imaging.c:1003 as non-NULL
when following default
1004 case IMAGING_TYPE_UINT8:
1005 if (!PyArg_ParseTuple(extremap, "ii", &i0, &i1))
1006 return NULL;
1007 /* FIXME: clip */
1008 extrema.u[0] = i0;
1009 extrema.u[1] = i1;
1010 break;
1011 case IMAGING_TYPE_INT32:
1012 if (!PyArg_ParseTuple(extremap, "ii", &i0, &i1))
1013 return NULL;
1014 extrema.i[0] = i0;
1015 extrema.i[1] = i1;
1016 break;
1017 case IMAGING_TYPE_FLOAT32:
1018 if (!PyArg_ParseTuple(extremap, "dd", &f0, &f1))
1019 return NULL;
1020 extrema.f[0] = (FLOAT32) f0;
1021 extrema.f[1] = (FLOAT32) f1;
1022 break;
1023 default:
1024 ep = NULL;
1025 break;
1026 }
1027 } else
1028 ep = NULL;
1029
1030 h = ImagingGetHistogram(self->image, (maskp) ? maskp->image : NULL, ep);
taking True path
1031
1032 if (!h)
when treating unknown struct ImagingHistogramInstance * from _imaging.c:1030 as non-NULL
taking False path
1033 return NULL;
1034
1035 /* Build an integer list containing the histogram */
1036 list = PyList_New(h->bands * 256);
when PyList_New() fails
1037 for (i = 0; i < h->bands * 256; i++) {
when considering range: 1 <= value <= 0x7fffffff
taking True path
1038 PyObject* item;
1039 item = PyInt_FromLong(h->histogram[i]);
when treating unknown long int * from _imaging.c:1039 as non-NULL
when PyInt_FromLong() succeeds
1040 if (item == NULL) {
taking False path
1041 Py_DECREF(list);
1042 list = NULL;
1043 break;
1044 }
1045 PyList_SetItem(list, i, item);
calling PyList_SetItem with NULL as argument 1 (list) at _imaging.c:1045
PyList_SetItem() invokes Py_TYPE() on the pointer via the PyList_Check() macro, thus accessing (NULL)->ob_type
found 1 similar trace(s) to this
1046 }
1047
1048 ImagingHistogramDelete(h);
1049
1050 return list;
1051 }
File: | _imaging.c |
Function: | _histogram |
Error: | dereferencing NULL (list->ob_refcnt) at _imaging.c:1041 |
981 static PyObject*
982 _histogram(ImagingObject* self, PyObject* args)
983 {
984 ImagingHistogram h;
985 PyObject* list;
986 int i;
987 union {
988 UINT8 u[2];
989 INT32 i[2];
990 FLOAT32 f[2];
991 } extrema;
992 void* ep;
993 int i0, i1;
994 double f0, f1;
995
996 PyObject* extremap = NULL;
997 ImagingObject* maskp = NULL;
998 if (!PyArg_ParseTuple(args, "|OO!", &extremap, &Imaging_Type, &maskp))
when PyArg_ParseTuple() succeeds
taking False path
999 return NULL;
1000
1001 if (extremap) {
taking True path
1002 ep = &extrema;
1003 switch (self->image->type) {
when treating unknown struct ImagingMemoryInstance * from _imaging.c:1003 as non-NULL
when following default
1004 case IMAGING_TYPE_UINT8:
1005 if (!PyArg_ParseTuple(extremap, "ii", &i0, &i1))
1006 return NULL;
1007 /* FIXME: clip */
1008 extrema.u[0] = i0;
1009 extrema.u[1] = i1;
1010 break;
1011 case IMAGING_TYPE_INT32:
1012 if (!PyArg_ParseTuple(extremap, "ii", &i0, &i1))
1013 return NULL;
1014 extrema.i[0] = i0;
1015 extrema.i[1] = i1;
1016 break;
1017 case IMAGING_TYPE_FLOAT32:
1018 if (!PyArg_ParseTuple(extremap, "dd", &f0, &f1))
1019 return NULL;
1020 extrema.f[0] = (FLOAT32) f0;
1021 extrema.f[1] = (FLOAT32) f1;
1022 break;
1023 default:
1024 ep = NULL;
1025 break;
1026 }
1027 } else
1028 ep = NULL;
1029
1030 h = ImagingGetHistogram(self->image, (maskp) ? maskp->image : NULL, ep);
taking True path
1031
1032 if (!h)
when treating unknown struct ImagingHistogramInstance * from _imaging.c:1030 as non-NULL
taking False path
1033 return NULL;
1034
1035 /* Build an integer list containing the histogram */
1036 list = PyList_New(h->bands * 256);
when PyList_New() fails
1037 for (i = 0; i < h->bands * 256; i++) {
when considering range: 1 <= value <= 0x7fffffff
taking True path
1038 PyObject* item;
1039 item = PyInt_FromLong(h->histogram[i]);
when treating unknown long int * from _imaging.c:1039 as non-NULL
when PyInt_FromLong() fails
1040 if (item == NULL) {
taking True path
1041 Py_DECREF(list);
dereferencing NULL (list->ob_refcnt) at _imaging.c:1041
found 1 similar trace(s) to this
1042 list = NULL;
1043 break;
1044 }
1045 PyList_SetItem(list, i, item);
1046 }
1047
1048 ImagingHistogramDelete(h);
1049
1050 return list;
1051 }
File: | _imaging.c |
Function: | _histogram |
Error: | returning (PyObject*)NULL without setting an exception |
981 static PyObject*
982 _histogram(ImagingObject* self, PyObject* args)
983 {
984 ImagingHistogram h;
985 PyObject* list;
986 int i;
987 union {
988 UINT8 u[2];
989 INT32 i[2];
990 FLOAT32 f[2];
991 } extrema;
992 void* ep;
993 int i0, i1;
994 double f0, f1;
995
996 PyObject* extremap = NULL;
997 ImagingObject* maskp = NULL;
998 if (!PyArg_ParseTuple(args, "|OO!", &extremap, &Imaging_Type, &maskp))
when PyArg_ParseTuple() succeeds
taking False path
999 return NULL;
1000
1001 if (extremap) {
taking True path
1002 ep = &extrema;
1003 switch (self->image->type) {
when treating unknown struct ImagingMemoryInstance * from _imaging.c:1003 as non-NULL
when following default
1004 case IMAGING_TYPE_UINT8:
1005 if (!PyArg_ParseTuple(extremap, "ii", &i0, &i1))
1006 return NULL;
1007 /* FIXME: clip */
1008 extrema.u[0] = i0;
1009 extrema.u[1] = i1;
1010 break;
1011 case IMAGING_TYPE_INT32:
1012 if (!PyArg_ParseTuple(extremap, "ii", &i0, &i1))
1013 return NULL;
1014 extrema.i[0] = i0;
1015 extrema.i[1] = i1;
1016 break;
1017 case IMAGING_TYPE_FLOAT32:
1018 if (!PyArg_ParseTuple(extremap, "dd", &f0, &f1))
1019 return NULL;
1020 extrema.f[0] = (FLOAT32) f0;
1021 extrema.f[1] = (FLOAT32) f1;
1022 break;
1023 default:
1024 ep = NULL;
1025 break;
1026 }
1027 } else
1028 ep = NULL;
1029
1030 h = ImagingGetHistogram(self->image, (maskp) ? maskp->image : NULL, ep);
taking True path
1031
1032 if (!h)
when treating unknown struct ImagingHistogramInstance * from _imaging.c:1030 as NULL
taking True path
1033 return NULL;
1034
1035 /* Build an integer list containing the histogram */
1036 list = PyList_New(h->bands * 256);
1037 for (i = 0; i < h->bands * 256; i++) {
1038 PyObject* item;
1039 item = PyInt_FromLong(h->histogram[i]);
1040 if (item == NULL) {
1041 Py_DECREF(list);
1042 list = NULL;
1043 break;
1044 }
1045 PyList_SetItem(list, i, item);
1046 }
1047
1048 ImagingHistogramDelete(h);
1049
1050 return list;
1051 }
returning (PyObject*)NULL without setting an exception
found 1 similar trace(s) to this