File: player.c
Function: player_new
Error: ob_refcnt of new ref from call to PyObject_CallMethod is 1 too high
27 /* create a new player */
28 Player* player_new(gint direction, gboolean show_faces, gchar *script, Trick *trick, GtkWidget *widget)
29 {
30 	/* create the player with default values */
31 	Player *player;
32 	player = g_new(Player, 1);
taking False path
when considering range: -0x80000000 <= value <= -1
taking True path
taking False path
taking True path
33 	player->direction = direction;
when treating unknown void * from player.c:32 as non-NULL
34 	player->score_round = 0;
35 	player->score_total = 0;
36 	player->trick = trick;
37 	player->name = NULL;
38 	player->cards_taken = NULL;
39 	
40 	/* assign a hand of cards */
41 	player->hand = cards_hand_new(direction, show_faces);
42 	
43 	/* Load the Python AI */
44 	PyObject *module, *dict, *player_args, *result;
45 	
46 	module = PyImport_AddModule("__main__");
when PyImport_AddModule() succeeds
47 	dict = PyModule_GetDict(module);
48 	
49 	/* Create a new player AI instance by calling the classname in Python */
50 	gchar *class = (script ? script : "StockAI");
when taking True path
51 	
52 	player_args = Py_BuildValue("(iOOO)",
when PyDict_GetItemString() succeeds
when PyDict_GetItemString() succeeds
when PyDict_GetItemString() succeeds
when Py_BuildValue() succeeds
53 		direction, PyDict_GetItemString(dict, "trick"),
54 		PyDict_GetItemString(dict, "score"),
55 		PyDict_GetItemString(dict, "rules")
56 	);
57 
58 	player->ai = PyObject_Call(PyDict_GetItemString(dict, class), player_args, NULL);
when treating unknown gchar * from player.c:28 as non-NULL
when PyDict_GetItemString() succeeds
when PyObject_Call() succeeds
59 	Py_DECREF(player_args);
when taking False path
calling tp_dealloc on new ref from call to Py_BuildValue allocated at player.c:52
60 	
61 	if (PyErr_Occurred())
PyErr_Occurred()
taking False path
62 	{
63 		PyErr_Print();
64 		g_assert_not_reached();
65 	}
66 	
67 	/* Assign the new player AI instance in Python */
68 	result = PyObject_CallFunction(PyDict_GetItemString(dict, "player_set"), "Oi", player->ai, direction);
when PyDict_GetItemString() succeeds
when PyObject_CallFunction() succeeds
69 	Py_DECREF(result);
when taking True path
70 	
71 	/* create a pango layout and set the player name */
72 	player->layout = gtk_widget_create_pango_layout(widget, NULL);
73 
74 	if (script)
taking True path
75 	{
76 		result = PyObject_CallMethod(player->ai, "get_name", NULL);
when PyObject_CallMethod() succeeds
new ref from call to PyObject_CallMethod allocated at: 		result = PyObject_CallMethod(player->ai, "get_name", NULL);
ob_refcnt is now refs: 1 + N where N >= 0
77 		player->name = strdup(PyString_AsString(result));
when PyString_AsString() succeeds
78 	}
79 	else
80 	{
81 		player->name = strdup(g_get_real_name());
82 	}
83 	
84 	gchar *name = g_strconcat("<span foreground=\"white\"><b>", player->name, "</b></span>", NULL);
85 	pango_layout_set_markup(player->layout, name, -1);
86 	g_free(name);
87 	
88 	return player;
returning
ob_refcnt of new ref from call to PyObject_CallMethod is 1 too high
was expecting final ob_refcnt to be N + 0 (for some unknown N)
but final ob_refcnt is N + 1
found 8 similar trace(s) to this
89 }

File: player.c
Function: player_new
Error: calling PyString_AsString with NULL as argument 1 (result) at player.c:77
27 /* create a new player */
28 Player* player_new(gint direction, gboolean show_faces, gchar *script, Trick *trick, GtkWidget *widget)
29 {
30 	/* create the player with default values */
31 	Player *player;
32 	player = g_new(Player, 1);
taking False path
when considering range: -0x80000000 <= value <= -1
taking True path
taking False path
taking True path
33 	player->direction = direction;
when treating unknown void * from player.c:32 as non-NULL
34 	player->score_round = 0;
35 	player->score_total = 0;
36 	player->trick = trick;
37 	player->name = NULL;
38 	player->cards_taken = NULL;
39 	
40 	/* assign a hand of cards */
41 	player->hand = cards_hand_new(direction, show_faces);
42 	
43 	/* Load the Python AI */
44 	PyObject *module, *dict, *player_args, *result;
45 	
46 	module = PyImport_AddModule("__main__");
when PyImport_AddModule() succeeds
47 	dict = PyModule_GetDict(module);
48 	
49 	/* Create a new player AI instance by calling the classname in Python */
50 	gchar *class = (script ? script : "StockAI");
when taking True path
51 	
52 	player_args = Py_BuildValue("(iOOO)",
when PyDict_GetItemString() succeeds
when PyDict_GetItemString() succeeds
when PyDict_GetItemString() succeeds
when Py_BuildValue() succeeds
53 		direction, PyDict_GetItemString(dict, "trick"),
54 		PyDict_GetItemString(dict, "score"),
55 		PyDict_GetItemString(dict, "rules")
56 	);
57 
58 	player->ai = PyObject_Call(PyDict_GetItemString(dict, class), player_args, NULL);
when treating unknown gchar * from player.c:28 as non-NULL
when PyDict_GetItemString() succeeds
when PyObject_Call() succeeds
59 	Py_DECREF(player_args);
when taking True path
60 	
61 	if (PyErr_Occurred())
PyErr_Occurred()
taking False path
62 	{
63 		PyErr_Print();
64 		g_assert_not_reached();
65 	}
66 	
67 	/* Assign the new player AI instance in Python */
68 	result = PyObject_CallFunction(PyDict_GetItemString(dict, "player_set"), "Oi", player->ai, direction);
when PyDict_GetItemString() succeeds
when PyObject_CallFunction() succeeds
69 	Py_DECREF(result);
when taking True path
70 	
71 	/* create a pango layout and set the player name */
72 	player->layout = gtk_widget_create_pango_layout(widget, NULL);
73 
74 	if (script)
taking True path
75 	{
76 		result = PyObject_CallMethod(player->ai, "get_name", NULL);
when PyObject_CallMethod() fails
77 		player->name = strdup(PyString_AsString(result));
calling PyString_AsString with NULL as argument 1 (result) at player.c:77
PyString_AsString() invokes Py_TYPE() on the pointer via the PyString_Check() macro, thus accessing (NULL)->ob_type
found 3 similar trace(s) to this
78 	}
79 	else
80 	{
81 		player->name = strdup(g_get_real_name());
82 	}
83 	
84 	gchar *name = g_strconcat("<span foreground=\"white\"><b>", player->name, "</b></span>", NULL);
85 	pango_layout_set_markup(player->layout, name, -1);
86 	g_free(name);
87 	
88 	return player;
89 }

File: player.c
Function: player_new
Error: dereferencing NULL (result->ob_refcnt) at player.c:69
27 /* create a new player */
28 Player* player_new(gint direction, gboolean show_faces, gchar *script, Trick *trick, GtkWidget *widget)
29 {
30 	/* create the player with default values */
31 	Player *player;
32 	player = g_new(Player, 1);
taking False path
when considering range: -0x80000000 <= value <= -1
taking True path
taking False path
taking True path
33 	player->direction = direction;
when treating unknown void * from player.c:32 as non-NULL
34 	player->score_round = 0;
35 	player->score_total = 0;
36 	player->trick = trick;
37 	player->name = NULL;
38 	player->cards_taken = NULL;
39 	
40 	/* assign a hand of cards */
41 	player->hand = cards_hand_new(direction, show_faces);
42 	
43 	/* Load the Python AI */
44 	PyObject *module, *dict, *player_args, *result;
45 	
46 	module = PyImport_AddModule("__main__");
when PyImport_AddModule() succeeds
47 	dict = PyModule_GetDict(module);
48 	
49 	/* Create a new player AI instance by calling the classname in Python */
50 	gchar *class = (script ? script : "StockAI");
when taking True path
51 	
52 	player_args = Py_BuildValue("(iOOO)",
when PyDict_GetItemString() succeeds
when PyDict_GetItemString() succeeds
when PyDict_GetItemString() succeeds
when Py_BuildValue() succeeds
53 		direction, PyDict_GetItemString(dict, "trick"),
54 		PyDict_GetItemString(dict, "score"),
55 		PyDict_GetItemString(dict, "rules")
56 	);
57 
58 	player->ai = PyObject_Call(PyDict_GetItemString(dict, class), player_args, NULL);
when treating unknown gchar * from player.c:28 as non-NULL
when PyDict_GetItemString() succeeds
when PyObject_Call() succeeds
59 	Py_DECREF(player_args);
when taking True path
60 	
61 	if (PyErr_Occurred())
PyErr_Occurred()
taking False path
62 	{
63 		PyErr_Print();
64 		g_assert_not_reached();
65 	}
66 	
67 	/* Assign the new player AI instance in Python */
68 	result = PyObject_CallFunction(PyDict_GetItemString(dict, "player_set"), "Oi", player->ai, direction);
when PyDict_GetItemString() succeeds
when PyObject_CallFunction() fails
69 	Py_DECREF(result);
dereferencing NULL (result->ob_refcnt) at player.c:69
found 1 similar trace(s) to this
70 	
71 	/* create a pango layout and set the player name */
72 	player->layout = gtk_widget_create_pango_layout(widget, NULL);
73 
74 	if (script)
75 	{
76 		result = PyObject_CallMethod(player->ai, "get_name", NULL);
77 		player->name = strdup(PyString_AsString(result));
78 	}
79 	else
80 	{
81 		player->name = strdup(g_get_real_name());
82 	}
83 	
84 	gchar *name = g_strconcat("<span foreground=\"white\"><b>", player->name, "</b></span>", NULL);
85 	pango_layout_set_markup(player->layout, name, -1);
86 	g_free(name);
87 	
88 	return player;
89 }