@@ -1506,7 +1506,6 @@ static int common_conf_set_special(PyObject *confdict, rd_kafka_conf_t *conf,
1506
1506
!= RD_KAFKA_CONF_OK ) {
1507
1507
cfl_PyErr_Format (RD_KAFKA_RESP_ERR__INVALID_ARG ,
1508
1508
"%s" , errstr );
1509
-
1510
1509
Py_DECREF (vs );
1511
1510
Py_XDECREF (vs8 );
1512
1511
return 0 ;
@@ -1585,8 +1584,8 @@ rd_kafka_conf_t *common_conf_setup (rd_kafka_type_t ktype,
1585
1584
/*
1586
1585
* Set debug contexts first to capture all events including plugin loading
1587
1586
*/
1588
- if ((vo = PyDict_GetItemString (confdict , "debug" )))
1589
- if ( !common_conf_set_special (confdict , conf , "debug" , vo ))
1587
+ if ((vo = PyDict_GetItemString (confdict , "debug" )) &&
1588
+ !common_conf_set_special (confdict , conf , "debug" , vo ))
1590
1589
goto outer_err ;
1591
1590
1592
1591
/*
@@ -1598,40 +1597,15 @@ rd_kafka_conf_t *common_conf_setup (rd_kafka_type_t ktype,
1598
1597
* correct order.
1599
1598
*/
1600
1599
if ((vo = PyDict_GetItemString (confdict , "plugin.library.paths" ))) {
1601
- const char * v ;
1602
- char errstr [256 ];
1603
- PyObject * resolved ;
1604
- PyObject * vs = NULL , * vs8 = NULL ;
1605
-
1606
1600
/* Resolve plugin paths */
1601
+ PyObject * resolved ;
1607
1602
resolved = resolve_plugins (vo );
1608
1603
if (!resolved )
1609
1604
goto outer_err ;
1610
1605
1611
1606
if (!common_conf_set_special (confdict , conf , "plugin.library.paths" , vo )) {
1612
1607
Py_DECREF (resolved );
1613
- rd_kafka_conf_destroy (conf );
1614
- Py_DECREF (confdict );
1615
-
1616
- return NULL ;
1617
- }
1618
-
1619
- Py_DECREF (resolved );
1620
-
1621
- v = cfl_PyUnistr_AsUTF8 (vs , & vs8 );
1622
-
1623
- if (rd_kafka_conf_set (conf , "plugin.library.paths" , v , errstr , sizeof (errstr ))
1624
- != RD_KAFKA_CONF_OK ) {
1625
- cfl_PyErr_Format (RD_KAFKA_RESP_ERR__INVALID_ARG ,
1626
- "%s" , errstr );
1627
-
1628
- rd_kafka_conf_destroy (conf );
1629
- Py_DECREF (confdict );
1630
-
1631
- Py_XDECREF (vs8 );
1632
- Py_XDECREF (vs );
1633
-
1634
- return NULL ;
1608
+ goto outer_err ;
1635
1609
}
1636
1610
Py_DECREF (resolved );
1637
1611
}
@@ -1643,16 +1617,15 @@ rd_kafka_conf_t *common_conf_setup (rd_kafka_type_t ktype,
1643
1617
"set default topic configuration values in the global dict");
1644
1618
*/
1645
1619
if (PyDict_Update (confdict , vo ) == -1 ) {
1646
- rd_kafka_conf_destroy (conf );
1647
- Py_DECREF (confdict );
1648
- return NULL ;
1620
+ goto outer_err ;
1649
1621
}
1650
1622
PyDict_DelItemString (confdict , "default.topic.config" );
1651
1623
}
1652
1624
1653
1625
/* Convert config dict to config key-value pairs. */
1654
1626
while (PyDict_Next (confdict , & pos , & ko , & vo )) {
1655
- PyObject * ks , * ks8 ;
1627
+ PyObject * ks ;
1628
+ PyObject * ks8 = NULL ;
1656
1629
PyObject * vs = NULL , * vs8 = NULL ;
1657
1630
const char * k ;
1658
1631
const char * v ;
@@ -1663,10 +1636,7 @@ rd_kafka_conf_t *common_conf_setup (rd_kafka_type_t ktype,
1663
1636
PyErr_SetString (PyExc_TypeError ,
1664
1637
"expected configuration property name "
1665
1638
"as type unicode string" );
1666
- rd_kafka_conf_destroy (conf );
1667
- Py_DECREF (confdict );
1668
-
1669
- return NULL ;
1639
+ goto inner_err ;
1670
1640
}
1671
1641
1672
1642
k = cfl_PyUnistr_AsUTF8 (ks , & ks8 );
@@ -1675,13 +1645,7 @@ rd_kafka_conf_t *common_conf_setup (rd_kafka_type_t ktype,
1675
1645
PyErr_SetString (PyExc_TypeError ,
1676
1646
"expected error_cb property "
1677
1647
"as a callable function" );
1678
- rd_kafka_conf_destroy (conf );
1679
- Py_DECREF (confdict );
1680
-
1681
- Py_XDECREF (ks8 );
1682
- Py_DECREF (ks );
1683
-
1684
- return NULL ;
1648
+ goto inner_err ;
1685
1649
}
1686
1650
if (h -> error_cb ) {
1687
1651
Py_DECREF (h -> error_cb );
@@ -1699,13 +1663,7 @@ rd_kafka_conf_t *common_conf_setup (rd_kafka_type_t ktype,
1699
1663
PyErr_SetString (PyExc_ValueError ,
1700
1664
"expected throttle_cb property "
1701
1665
"as a callable function" );
1702
- rd_kafka_conf_destroy (conf );
1703
- Py_DECREF (confdict );
1704
-
1705
- Py_XDECREF (ks8 );
1706
- Py_DECREF (ks );
1707
-
1708
- return NULL ;
1666
+ goto inner_err ;
1709
1667
}
1710
1668
if (h -> throttle_cb ) {
1711
1669
Py_DECREF (h -> throttle_cb );
@@ -1723,13 +1681,7 @@ rd_kafka_conf_t *common_conf_setup (rd_kafka_type_t ktype,
1723
1681
PyErr_SetString (PyExc_TypeError ,
1724
1682
"expected stats_cb property "
1725
1683
"as a callable function" );
1726
- rd_kafka_conf_destroy (conf );
1727
- Py_DECREF (confdict );
1728
-
1729
- Py_XDECREF (ks8 );
1730
- Py_DECREF (ks );
1731
-
1732
- return NULL ;
1684
+ goto inner_err ;
1733
1685
}
1734
1686
1735
1687
if (h -> stats_cb ) {
@@ -1765,13 +1717,7 @@ rd_kafka_conf_t *common_conf_setup (rd_kafka_type_t ktype,
1765
1717
r = consumer_conf_set_special (h , conf , k , vo );
1766
1718
if (r == -1 ) {
1767
1719
/* Error */
1768
- Py_XDECREF (ks8 );
1769
- Py_DECREF (ks );
1770
- rd_kafka_conf_destroy (conf );
1771
- Py_DECREF (confdict );
1772
-
1773
- return NULL ;
1774
-
1720
+ goto inner_err ;
1775
1721
} else if (r == 1 ) {
1776
1722
/* Handled */
1777
1723
continue ;
@@ -1789,13 +1735,7 @@ rd_kafka_conf_t *common_conf_setup (rd_kafka_type_t ktype,
1789
1735
"expected configuration "
1790
1736
"property value as type "
1791
1737
"unicode string" );
1792
- rd_kafka_conf_destroy (conf );
1793
- Py_DECREF (confdict );
1794
-
1795
- Py_XDECREF (ks8 );
1796
- Py_DECREF (ks );
1797
-
1798
- return NULL ;
1738
+ goto inner_err ;
1799
1739
}
1800
1740
v = cfl_PyUnistr_AsUTF8 (vs , & vs8 );
1801
1741
}
@@ -1804,15 +1744,7 @@ rd_kafka_conf_t *common_conf_setup (rd_kafka_type_t ktype,
1804
1744
RD_KAFKA_CONF_OK ) {
1805
1745
cfl_PyErr_Format (RD_KAFKA_RESP_ERR__INVALID_ARG ,
1806
1746
"%s" , errstr );
1807
- rd_kafka_conf_destroy (conf );
1808
- Py_DECREF (confdict );
1809
-
1810
- Py_XDECREF (vs8 );
1811
- Py_XDECREF (vs );
1812
- Py_XDECREF (ks8 );
1813
- Py_DECREF (ks );
1814
-
1815
- return NULL ;
1747
+ goto inner_err ;
1816
1748
}
1817
1749
1818
1750
Py_XDECREF (vs8 );
@@ -1863,6 +1795,12 @@ rd_kafka_conf_t *common_conf_setup (rd_kafka_type_t ktype,
1863
1795
h -> initiated = 1 ;
1864
1796
1865
1797
return conf ;
1798
+
1799
+ outer_err :
1800
+ Py_DECREF (confdict );
1801
+ rd_kafka_conf_destroy (conf );
1802
+
1803
+ return NULL ;
1866
1804
}
1867
1805
1868
1806
0 commit comments