Bug Summary

File:_imagingtk.c
Warning:line 77, column 9
PyObject ownership leak with reference count of 1

Annotated Source Code

Press '?' to see keyboard shortcuts

clang -cc1 -cc1 -triple x86_64-unknown-linux-gnu -analyze -disable-free -disable-llvm-verifier -discard-value-names -main-file-name _imagingtk.c -analyzer-store=region -analyzer-opt-analyze-nested-blocks -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -analyzer-output=html -analyzer-checker=python -analyzer-disable-checker=deadcode -analyzer-config prune-paths=true,suppress-c++-stdlib=true,suppress-null-return-paths=false,crosscheck-with-z3=true,model-path=/opt/pyrefcon/lib/pyrefcon/models/models -analyzer-config experimental-enable-naive-ctu-analysis=true,ctu-dir=/tmp/pyrefcon/Pillow/csa-scan,ctu-index-name=/tmp/pyrefcon/Pillow/csa-scan/externalDefMap.txt,ctu-invocation-list=/tmp/pyrefcon/Pillow/csa-scan/invocations.yaml,display-ctu-progress=false -setup-static-analyzer -analyzer-config-compatibility-mode=true -mrelocation-model pic -pic-level 2 -fhalf-no-semantic-interposition -mframe-pointer=none -fmath-errno -fno-rounding-math -mconstructor-aliases -munwind-tables -target-cpu x86-64 -tune-cpu generic -debug-info-kind=limited -dwarf-version=4 -debugger-tuning=gdb -fcoverage-compilation-dir=/tmp/pyrefcon/Pillow -resource-dir /opt/pyrefcon/lib/clang/13.0.0 -isystem /opt/pyrefcon/lib/pyrefcon/models/python3.8 -D NDEBUG -D _FORTIFY_SOURCE=2 -I /usr/include/freetype2 -I /usr/include/openjpeg-2.3 -I /tmp/pyrefcon/Pillow -I /usr/include/x86_64-linux-gnu -I /usr/include/fribidi -I /usr/include -internal-isystem /opt/pyrefcon/lib/clang/13.0.0/include -internal-isystem /usr/local/include -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/10/../../../../x86_64-linux-gnu/include -internal-externc-isystem /usr/include/x86_64-linux-gnu -internal-externc-isystem /include -internal-externc-isystem /usr/include -O2 -Wno-unused-result -Wsign-compare -Wall -Wformat -Werror=format-security -Wformat -Werror=format-security -Wdate-time -fdebug-compilation-dir=/tmp/pyrefcon/Pillow -ferror-limit 19 -fwrapv -pthread -stack-protector 2 -fgnuc-version=4.2.1 -vectorize-loops -vectorize-slp -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /tmp/pyrefcon/Pillow/csa-scan/reports -x c src/_imagingtk.c

src/_imagingtk.c

1/*
2 * The Python Imaging Library.
3 *
4 * tkinter hooks
5 *
6 * history:
7 * 99-07-26 fl created
8 * 99-08-15 fl moved to its own support module
9 *
10 * Copyright (c) Secret Labs AB 1999.
11 *
12 * See the README file for information on usage and redistribution.
13 */
14
15#include "Python.h"
16#include "libImaging/Imaging.h"
17
18#include "Tk/_tkmini.h"
19
20/* must link with Tk/tkImaging.c */
21extern void
22TkImaging_Init(Tcl_Interp *interp);
23extern int
24load_tkinter_funcs(void);
25
26/* copied from _tkinter.c (this isn't as bad as it may seem: for new
27 versions, we use _tkinter's interpaddr hook instead, and all older
28 versions use this structure layout) */
29
30typedef struct {
31 PyObject_HEADPyObject ob_base; Tcl_Interp *interp;
32} TkappObject;
33
34static PyObject *
35_tkinit(PyObject *self, PyObject *args) {
36 Tcl_Interp *interp;
37
38 PyObject *arg;
39 int is_interp;
40 if (!PyArg_ParseTuple(args, "Oi", &arg, &is_interp)) {
41 return NULL((void*)0);
42 }
43
44 if (is_interp) {
45 interp = (Tcl_Interp *)PyLong_AsVoidPtr(arg);
46 } else {
47 TkappObject *app;
48 /* Do it the hard way. This will break if the TkappObject
49 layout changes */
50 app = (TkappObject *)PyLong_AsVoidPtr(arg);
51 interp = app->interp;
52 }
53
54 /* This will bomb if interp is invalid... */
55 TkImaging_Init(interp);
56
57 Py_INCREF(Py_None)_Py_INCREF(((PyObject*)((&_Py_NoneStruct))));
58 return Py_None(&_Py_NoneStruct);
59}
60
61static PyMethodDef functions[] = {
62 /* Tkinter interface stuff */
63 {"tkinit", (PyCFunction)_tkinit, 1},
64 {NULL((void*)0), NULL((void*)0)} /* sentinel */
65};
66
67PyMODINIT_FUNCPyObject*
68PyInit__imagingtk(void) {
69 static PyModuleDef module_def = {
70 PyModuleDef_HEAD_INIT{ { 1, ((void*)0) }, ((void*)0), 0, ((void*)0), },
71 "_imagingtk", /* m_name */
72 NULL((void*)0), /* m_doc */
73 -1, /* m_size */
74 functions, /* m_methods */
75 };
76 PyObject *m;
77 m = PyModule_Create(&module_def)PyModule_Create2(&module_def, 1013);
1
Calling 'PyModule_Create2'
3
Returning from 'PyModule_Create2'
5
PyObject ownership leak with reference count of 1
78 return (load_tkinter_funcs() == 0) ? m : NULL((void*)0);
4
'?' condition is false
79}

/opt/pyrefcon/lib/pyrefcon/models/models/PyModule_Create2.model

1#ifndef PyModule_Create2
2struct _object;
3typedef struct _object PyObject;
4PyObject* clang_analyzer_PyObject_New_Reference();
5PyObject* PyModule_Create2(PyModuleDef *def, int module_api_version) {
6 return clang_analyzer_PyObject_New_Reference();
2
Setting reference count to 1
7}
8#else
9#warning "API PyModule_Create2 is defined as a macro."
10#endif