Skip to content

Commit 0361267

Browse files
committed
fix GCC issue?
1 parent 9f8b1cc commit 0361267

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

Modules/pyexpat.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1433,7 +1433,8 @@ xmlparse_handler_setter(PyObject *op, PyObject *v, void *closure)
14331433
return -1;
14341434
}
14351435

1436-
xmlhandler c_handler = NULL;
1436+
int used = 0;
1437+
xmlhandler_union c_handler;
14371438
if (v == Py_None) {
14381439
/* If this is the character data handler, and a character
14391440
data handler is already active, we need to be more
@@ -1450,18 +1451,21 @@ xmlparse_handler_setter(PyObject *op, PyObject *v, void *closure)
14501451
// The cast to union type '(union T)' is NOT a cast in the regular
14511452
// sense but a constructor as it does not produce an lvalue. It
14521453
// is a valid construction as per ISO C11, §6.5.2.5.
1453-
*c_handler = (xmlhandler_union){
1454+
c_handler = (xmlhandler_union){
14541455
.parser_and_data_and_int = noop_character_data_handler
14551456
};
1457+
used = 1;
14561458
}
14571459
v = NULL;
14581460
}
14591461
else if (v != NULL) {
14601462
Py_INCREF(v);
1461-
c_handler = &handler_info[handlernum].handler;
1463+
c_handler = handler_info[handlernum].handler;
1464+
used = 1;
14621465
}
14631466
Py_XSETREF(self->handlers[handlernum], v);
1464-
CALL_XML_HANDLER_SETTER(&handler_info[handlernum], self->itself, c_handler);
1467+
xmlhandler p_handler = used ? &c_handler : NULL;
1468+
CALL_XML_HANDLER_SETTER(&handler_info[handlernum], self->itself, p_handler);
14651469
return 0;
14661470
}
14671471

0 commit comments

Comments
 (0)