From: Lukáš Jiřiště Date: Fri, 16 Feb 2024 21:58:23 +0000 (+0100) Subject: Patch seg fault when simulating FET with NULL on gate X-Git-Url: https://git.ljiriste.work/?a=commitdiff_plain;h=e1d507fdbeb073d1e94af30e162a6605d037d920;p=FET_sim.git Patch seg fault when simulating FET with NULL on gate FETs with no connection on gate now default to closed. --- diff --git a/src/sim_main.c b/src/sim_main.c index 14cc9b5..37929e6 100644 --- a/src/sim_main.c +++ b/src/sim_main.c @@ -1,10 +1,16 @@ #include "FET_sim.h" #include "libft.h" +// Maybe an error should be return when gate is NULL static void update_mosfet(t_mosfet *mosfet) { t_state state; + if (!mosfet->gate) + { + mosfet->is_opened = 0; + return ; + } state = mosfet->gate->state; if (mosfet->type == p && state == on) mosfet->is_opened = 1;