From e1d507fdbeb073d1e94af30e162a6605d037d920 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Luk=C3=A1=C5=A1=20Ji=C5=99i=C5=A1t=C4=9B?= Date: Fri, 16 Feb 2024 22:58:23 +0100 Subject: [PATCH] Patch seg fault when simulating FET with NULL on gate FETs with no connection on gate now default to closed. --- src/sim_main.c | 6 ++++++ 1 file changed, 6 insertions(+) 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; -- 2.30.2