Skip to content

Commit a102d86

Browse files
author
Plamen
committed
Ensure size is non-zero.
1 parent ef48966 commit a102d86

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

gcc-python-tree.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -542,7 +542,8 @@ PyGccFunction_TypeObj_get_argument_types(struct PyGccTree * self, void *closure)
542542
{
543543
PyObject *result;
544544
PyObject *item;
545-
int i, size;
545+
int i;
546+
unsigned int size;
546547
tree iter;
547548
tree head = TYPE_ARG_TYPES(self->t.inner);
548549

@@ -554,10 +555,14 @@ PyGccFunction_TypeObj_get_argument_types(struct PyGccTree * self, void *closure)
554555
}
555556

556557
/* "size" should now be the length of the chain */
558+
559+
/* When a function with no input arguments is passed ( ex int foo())
560+
the previous code crashed. */
561+
if(size == 0)
562+
size = 1;
557563

558564
/* The last element in the list is a VOID_TYPE; don't add this;
559565
see dump_function_declaration() in gcc/tree-pretty-print.c */
560-
assert(size>0);
561566
size--;
562567

563568
result = PyTuple_New(size);

0 commit comments

Comments
 (0)