@@ -118,6 +118,9 @@ aaline(PyObject *self, PyObject *arg, PyObject *kwargs)
118118 return NULL ; /* Exception already set. */
119119 }
120120
121+ surf = pgSurface_AsSurface (surfobj );
122+ SURF_INIT_CHECK (surf )
123+
121124 if (!blend ) {
122125 if (PyErr_WarnEx (
123126 PyExc_DeprecationWarning ,
@@ -128,8 +131,6 @@ aaline(PyObject *self, PyObject *arg, PyObject *kwargs)
128131 }
129132 }
130133
131- surf = pgSurface_AsSurface (surfobj );
132-
133134 if (surf -> format -> BytesPerPixel <= 0 || surf -> format -> BytesPerPixel > 4 ) {
134135 return PyErr_Format (PyExc_ValueError ,
135136 "unsupported surface bit depth (%d) for drawing" ,
@@ -191,6 +192,7 @@ line(PyObject *self, PyObject *arg, PyObject *kwargs)
191192 }
192193
193194 surf = pgSurface_AsSurface (surfobj );
195+ SURF_INIT_CHECK (surf )
194196
195197 if (surf -> format -> BytesPerPixel <= 0 || surf -> format -> BytesPerPixel > 4 ) {
196198 return PyErr_Format (PyExc_ValueError ,
@@ -265,6 +267,7 @@ aalines(PyObject *self, PyObject *arg, PyObject *kwargs)
265267 }
266268
267269 surf = pgSurface_AsSurface (surfobj );
270+ SURF_INIT_CHECK (surf )
268271
269272 if (surf -> format -> BytesPerPixel <= 0 || surf -> format -> BytesPerPixel > 4 ) {
270273 return PyErr_Format (PyExc_ValueError ,
@@ -398,6 +401,7 @@ lines(PyObject *self, PyObject *arg, PyObject *kwargs)
398401 }
399402
400403 surf = pgSurface_AsSurface (surfobj );
404+ SURF_INIT_CHECK (surf )
401405
402406 if (surf -> format -> BytesPerPixel <= 0 || surf -> format -> BytesPerPixel > 4 ) {
403407 return PyErr_Format (PyExc_ValueError ,
@@ -520,6 +524,7 @@ arc(PyObject *self, PyObject *arg, PyObject *kwargs)
520524 }
521525
522526 surf = pgSurface_AsSurface (surfobj );
527+ SURF_INIT_CHECK (surf )
523528
524529 if (surf -> format -> BytesPerPixel <= 0 || surf -> format -> BytesPerPixel > 4 ) {
525530 return PyErr_Format (PyExc_ValueError ,
@@ -595,6 +600,7 @@ ellipse(PyObject *self, PyObject *arg, PyObject *kwargs)
595600 }
596601
597602 surf = pgSurface_AsSurface (surfobj );
603+ SURF_INIT_CHECK (surf )
598604
599605 if (surf -> format -> BytesPerPixel <= 0 || surf -> format -> BytesPerPixel > 4 ) {
600606 return PyErr_Format (PyExc_ValueError ,
@@ -678,6 +684,7 @@ circle(PyObject *self, PyObject *args, PyObject *kwargs)
678684 }
679685
680686 surf = pgSurface_AsSurface (surfobj );
687+ SURF_INIT_CHECK (surf )
681688
682689 if (surf -> format -> BytesPerPixel <= 0 || surf -> format -> BytesPerPixel > 4 ) {
683690 return PyErr_Format (PyExc_ValueError ,
@@ -767,6 +774,7 @@ polygon(PyObject *self, PyObject *arg, PyObject *kwargs)
767774 }
768775
769776 surf = pgSurface_AsSurface (surfobj );
777+ SURF_INIT_CHECK (surf )
770778
771779 if (surf -> format -> BytesPerPixel <= 0 || surf -> format -> BytesPerPixel > 4 ) {
772780 return PyErr_Format (PyExc_ValueError ,
@@ -884,6 +892,8 @@ rect(PyObject *self, PyObject *args, PyObject *kwargs)
884892 }
885893
886894 surf = pgSurface_AsSurface (surfobj );
895+ SURF_INIT_CHECK (surf )
896+
887897 if (surf -> format -> BytesPerPixel <= 0 || surf -> format -> BytesPerPixel > 4 ) {
888898 return PyErr_Format (PyExc_ValueError ,
889899 "unsupported surface bit depth (%d) for drawing" ,
0 commit comments