File: | bibtexmodule.c |
Function: | bib_reverse |
Error: | ob_refcnt of '*authobj' is 1 too high |
593 static PyObject *
594 bib_reverse (PyObject * self, PyObject * args)
595 {
596 BibtexField * field;
597 PyObject * tuple, * authobj, * tmp;
598 BibtexFieldType type;
599 BibtexAuthor * auth;
600
601 gint length, i, brace, quote;
602
603 if (! PyArg_ParseTuple(args, "iiO:reverse", & type, & brace, & tuple))
when PyArg_ParseTuple() succeeds
taking False path
604 return NULL;
605
606 field = bibtex_field_new (type);
607
608 if (field == NULL) {
when treating unknown struct BibtexField * from bibtexmodule.c:606 as non-NULL
taking False path
609 PyErr_SetString (PyExc_IOError, "can't create field");
610 return NULL;
611 }
612
613 quote = 1;
614
615 switch (field->type) {
when following case 1
616 case BIBTEX_VERBATIM:
617 quote = 0;
618
619 case BIBTEX_OTHER:
620 case BIBTEX_TITLE:
621 tmp = PyObject_Str (tuple);
622 if (tmp == NULL) return NULL;
623
624 field->text = g_strdup (PyString_AsString (tmp));
625 Py_DECREF (tmp);
626 break;
627
628 case BIBTEX_DATE:
629 tmp = PyObject_GetAttrString (tuple, "year");
630 if (tmp == NULL) return NULL;
631
632 if (tmp != Py_None)
633 field->field.date.year = PyInt_AsLong (tmp);
634 Py_DECREF (tmp);
635
636 tmp = PyObject_GetAttrString (tuple, "month");
637 if (tmp == NULL) return NULL;
638
639 if (tmp != Py_None)
640 field->field.date.month = PyInt_AsLong (tmp);
641 Py_DECREF (tmp);
642
643 tmp = PyObject_GetAttrString (tuple, "day");
644 if (tmp == NULL) return NULL;
645
646 if (tmp != Py_None)
647 field->field.date.day = PyInt_AsLong (tmp);
648 Py_DECREF (tmp);
649 break;
650
651 case BIBTEX_AUTHOR:
652 length = PySequence_Length (tuple);
when PySequence_Size() succeeds
653
654 if (length < 0) return NULL;
when considering range: 0 <= value <= 0x7fffffff
taking False path
655
656 field->field.author = bibtex_author_group_new ();
657
658 g_array_set_size (field->field.author, length);
659
660 for (i = 0; i < length; i++) {
when considering range: 1 <= length <= 0x7fffffff
taking True path
when considering length == (gint)1 from bibtexmodule.c:652
taking False path
661 authobj = PySequence_GetItem (tuple, i);
when PySequence_GetItem() succeeds
new ref from PySequence_GetItem allocated at: authobj = PySequence_GetItem (tuple, i);
ob_refcnt is now refs: 1 + N where N >= 0
662 auth = & g_array_index (field->field.author, BibtexAuthor, i);
when treating unknown struct BibtexAuthorGroup * from bibtexmodule.c:656 as non-NULL
663
664 tmp = PyObject_GetAttrString (authobj, "last");
when PyObject_GetAttrString() succeeds
665 if (tmp != Py_None) {
taking True path
666 auth->last = g_strdup (PyString_AsString (tmp));
when PyString_AsString() succeeds
when treating unknown struct BibtexAuthor * from bibtexmodule.c:662 as non-NULL
667 }
668 else {
669 auth->last = NULL;
670 }
671 Py_DECREF (tmp);
when taking True path
672 tmp = PyObject_GetAttrString (authobj, "first");
when PyObject_GetAttrString() succeeds
673 if (tmp != Py_None) {
taking True path
674 auth->first = g_strdup (PyString_AsString (tmp));
when PyString_AsString() succeeds
675 }
676 else {
677 auth->first = NULL;
678 }
679 Py_DECREF (tmp);
when taking True path
680 tmp = PyObject_GetAttrString (authobj, "lineage");
when PyObject_GetAttrString() succeeds
681 if (tmp != Py_None) {
taking True path
682 auth->lineage = g_strdup (PyString_AsString (tmp));
when PyString_AsString() succeeds
683 }
684 else {
685 auth->lineage = NULL;
686 }
687 Py_DECREF (tmp);
when taking True path
688 tmp = PyObject_GetAttrString (authobj, "honorific");
when PyObject_GetAttrString() succeeds
689 if (tmp != Py_None) {
taking True path
690 auth->honorific = g_strdup (PyString_AsString (tmp));
when PyString_AsString() fails
691 }
692 else {
693 auth->honorific = NULL;
694 }
695 Py_DECREF (tmp);
when taking True path
696 }
697 }
698
699 bibtex_reverse_field (field, brace, quote);
700
701 tmp = (PyObject *) PyObject_NEW (PyBibtexField_Object, & PyBibtexField_Type);
when PyObject_Init() succeeds
702 ((PyBibtexField_Object *) tmp)->obj = field;
703 return tmp;
704 }
ob_refcnt of '*authobj' 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 2 similar trace(s) to this
File: | bibtexmodule.c |
Function: | bib_reverse |
Error: | dereferencing NULL (MEM[(struct PyBibtexField_Object *)tmp].obj) at bibtexmodule.c:703 |
593 static PyObject *
594 bib_reverse (PyObject * self, PyObject * args)
595 {
596 BibtexField * field;
597 PyObject * tuple, * authobj, * tmp;
598 BibtexFieldType type;
599 BibtexAuthor * auth;
600
601 gint length, i, brace, quote;
602
603 if (! PyArg_ParseTuple(args, "iiO:reverse", & type, & brace, & tuple))
when PyArg_ParseTuple() succeeds
taking False path
604 return NULL;
605
606 field = bibtex_field_new (type);
607
608 if (field == NULL) {
when treating unknown struct BibtexField * from bibtexmodule.c:606 as non-NULL
taking False path
609 PyErr_SetString (PyExc_IOError, "can't create field");
610 return NULL;
611 }
612
613 quote = 1;
614
615 switch (field->type) {
when following case 1
616 case BIBTEX_VERBATIM:
617 quote = 0;
618
619 case BIBTEX_OTHER:
620 case BIBTEX_TITLE:
621 tmp = PyObject_Str (tuple);
622 if (tmp == NULL) return NULL;
623
624 field->text = g_strdup (PyString_AsString (tmp));
625 Py_DECREF (tmp);
626 break;
627
628 case BIBTEX_DATE:
629 tmp = PyObject_GetAttrString (tuple, "year");
630 if (tmp == NULL) return NULL;
631
632 if (tmp != Py_None)
633 field->field.date.year = PyInt_AsLong (tmp);
634 Py_DECREF (tmp);
635
636 tmp = PyObject_GetAttrString (tuple, "month");
637 if (tmp == NULL) return NULL;
638
639 if (tmp != Py_None)
640 field->field.date.month = PyInt_AsLong (tmp);
641 Py_DECREF (tmp);
642
643 tmp = PyObject_GetAttrString (tuple, "day");
644 if (tmp == NULL) return NULL;
645
646 if (tmp != Py_None)
647 field->field.date.day = PyInt_AsLong (tmp);
648 Py_DECREF (tmp);
649 break;
650
651 case BIBTEX_AUTHOR:
652 length = PySequence_Length (tuple);
when PySequence_Size() succeeds
653
654 if (length < 0) return NULL;
when considering range: 0 <= value <= 0x7fffffff
taking False path
655
656 field->field.author = bibtex_author_group_new ();
657
658 g_array_set_size (field->field.author, length);
659
660 for (i = 0; i < length; i++) {
when considering range: 1 <= length <= 0x7fffffff
taking True path
when considering length == (gint)1 from bibtexmodule.c:652
taking False path
661 authobj = PySequence_GetItem (tuple, i);
when PySequence_GetItem() succeeds
662 auth = & g_array_index (field->field.author, BibtexAuthor, i);
when treating unknown struct BibtexAuthorGroup * from bibtexmodule.c:656 as non-NULL
663
664 tmp = PyObject_GetAttrString (authobj, "last");
when PyObject_GetAttrString() succeeds
665 if (tmp != Py_None) {
taking True path
666 auth->last = g_strdup (PyString_AsString (tmp));
when PyString_AsString() succeeds
when treating unknown struct BibtexAuthor * from bibtexmodule.c:662 as non-NULL
667 }
668 else {
669 auth->last = NULL;
670 }
671 Py_DECREF (tmp);
when taking True path
672 tmp = PyObject_GetAttrString (authobj, "first");
when PyObject_GetAttrString() succeeds
673 if (tmp != Py_None) {
taking True path
674 auth->first = g_strdup (PyString_AsString (tmp));
when PyString_AsString() succeeds
675 }
676 else {
677 auth->first = NULL;
678 }
679 Py_DECREF (tmp);
when taking True path
680 tmp = PyObject_GetAttrString (authobj, "lineage");
when PyObject_GetAttrString() succeeds
681 if (tmp != Py_None) {
taking True path
682 auth->lineage = g_strdup (PyString_AsString (tmp));
when PyString_AsString() succeeds
683 }
684 else {
685 auth->lineage = NULL;
686 }
687 Py_DECREF (tmp);
when taking True path
688 tmp = PyObject_GetAttrString (authobj, "honorific");
when PyObject_GetAttrString() succeeds
689 if (tmp != Py_None) {
taking True path
690 auth->honorific = g_strdup (PyString_AsString (tmp));
when PyString_AsString() fails
691 }
692 else {
693 auth->honorific = NULL;
694 }
695 Py_DECREF (tmp);
when taking True path
696 }
697 }
698
699 bibtex_reverse_field (field, brace, quote);
700
701 tmp = (PyObject *) PyObject_NEW (PyBibtexField_Object, & PyBibtexField_Type);
when PyObject_Init() fails
702 ((PyBibtexField_Object *) tmp)->obj = field;
dereferencing NULL (MEM[(struct PyBibtexField_Object *)tmp].obj) at bibtexmodule.c:703
found 6 similar trace(s) to this
703 return tmp;
704 }
File: | bibtexmodule.c |
Function: | bib_reverse |
Error: | returning (PyObject*)NULL without setting an exception |
593 static PyObject *
594 bib_reverse (PyObject * self, PyObject * args)
595 {
596 BibtexField * field;
597 PyObject * tuple, * authobj, * tmp;
598 BibtexFieldType type;
599 BibtexAuthor * auth;
600
601 gint length, i, brace, quote;
602
603 if (! PyArg_ParseTuple(args, "iiO:reverse", & type, & brace, & tuple))
when PyArg_ParseTuple() succeeds
taking False path
604 return NULL;
605
606 field = bibtex_field_new (type);
607
608 if (field == NULL) {
when treating unknown struct BibtexField * from bibtexmodule.c:606 as non-NULL
taking False path
609 PyErr_SetString (PyExc_IOError, "can't create field");
610 return NULL;
611 }
612
613 quote = 1;
614
615 switch (field->type) {
when following case 1
616 case BIBTEX_VERBATIM:
617 quote = 0;
618
619 case BIBTEX_OTHER:
620 case BIBTEX_TITLE:
621 tmp = PyObject_Str (tuple);
622 if (tmp == NULL) return NULL;
623
624 field->text = g_strdup (PyString_AsString (tmp));
625 Py_DECREF (tmp);
626 break;
627
628 case BIBTEX_DATE:
629 tmp = PyObject_GetAttrString (tuple, "year");
630 if (tmp == NULL) return NULL;
631
632 if (tmp != Py_None)
633 field->field.date.year = PyInt_AsLong (tmp);
634 Py_DECREF (tmp);
635
636 tmp = PyObject_GetAttrString (tuple, "month");
637 if (tmp == NULL) return NULL;
638
639 if (tmp != Py_None)
640 field->field.date.month = PyInt_AsLong (tmp);
641 Py_DECREF (tmp);
642
643 tmp = PyObject_GetAttrString (tuple, "day");
644 if (tmp == NULL) return NULL;
645
646 if (tmp != Py_None)
647 field->field.date.day = PyInt_AsLong (tmp);
648 Py_DECREF (tmp);
649 break;
650
651 case BIBTEX_AUTHOR:
652 length = PySequence_Length (tuple);
when PySequence_Size() succeeds
653
654 if (length < 0) return NULL;
when considering range: -0x80000000 <= value <= -1
taking True path
655
656 field->field.author = bibtex_author_group_new ();
657
658 g_array_set_size (field->field.author, length);
659
660 for (i = 0; i < length; i++) {
661 authobj = PySequence_GetItem (tuple, i);
662 auth = & g_array_index (field->field.author, BibtexAuthor, i);
663
664 tmp = PyObject_GetAttrString (authobj, "last");
665 if (tmp != Py_None) {
666 auth->last = g_strdup (PyString_AsString (tmp));
667 }
668 else {
669 auth->last = NULL;
670 }
671 Py_DECREF (tmp);
672 tmp = PyObject_GetAttrString (authobj, "first");
673 if (tmp != Py_None) {
674 auth->first = g_strdup (PyString_AsString (tmp));
675 }
676 else {
677 auth->first = NULL;
678 }
679 Py_DECREF (tmp);
680 tmp = PyObject_GetAttrString (authobj, "lineage");
681 if (tmp != Py_None) {
682 auth->lineage = g_strdup (PyString_AsString (tmp));
683 }
684 else {
685 auth->lineage = NULL;
686 }
687 Py_DECREF (tmp);
688 tmp = PyObject_GetAttrString (authobj, "honorific");
689 if (tmp != Py_None) {
690 auth->honorific = g_strdup (PyString_AsString (tmp));
691 }
692 else {
693 auth->honorific = NULL;
694 }
695 Py_DECREF (tmp);
696 }
697 }
698
699 bibtex_reverse_field (field, brace, quote);
700
701 tmp = (PyObject *) PyObject_NEW (PyBibtexField_Object, & PyBibtexField_Type);
702 ((PyBibtexField_Object *) tmp)->obj = field;
703 return tmp;
704 }
returning (PyObject*)NULL without setting an exception