gh-123290: fix reference leaks in the error-branches of _cursesmodule.c
#123953
+211
−147
_cursesmodule.c
#123953