transporthandler: fix ipmid crash

The ipmid crashes when the set LAN configuration command is executed,
and the journal log shows the following messages.

```
/usr/include/c++/14.2.0/optional:475: constexpr _Tp&
std::_Optional_base_impl<_Tp, _Dp>::_M_get() [with _Tp =
ipmi::transport::IfAddr<2>; _Dp =
std::_Optional_base<ipmi::transport::IfAddr<2>, false, false>]:
Assertion 'this->_M_is_engaged()' failed.
```

Add checks to ensure that the return value of getIfAddr or getIfAddr4 is
not null.

Tested:
1. Change to static source and set satatic IP
ipmitool lan set 1 ipsrc static; ipmitool lan set 1 ipaddr 10.0.0.10;
ipmitool lan set 1 netmask 255.255.255.0; ipmitool lan set 1 defgw
ipaddr 10.0.0.254

2. Check the IP Lan print.
ipmitool lan print 1

Expect the IP address and IP source address report accordingly.

Change-Id: I1ddfcf0addbed466a385b1e6b9e232154c440262
Signed-off-by: Vince Chang <vince_chang@aspeedtech.com>
diff --git a/transporthandler.cpp b/transporthandler.cpp
index 772925e..8763f5f 100644
--- a/transporthandler.cpp
+++ b/transporthandler.cpp
@@ -271,7 +271,7 @@
     for (uint8_t i = 0; i < MAX_IPV4_ADDRESSES; ++i)
     {
         ifaddr4 = getIfAddr<AF_INET>(bus, params, i, originsV4);
-        if (src == ifaddr4->origin)
+        if (ifaddr4 && src == ifaddr4->origin)
         {
             break;
         }
@@ -301,12 +301,14 @@
         elog<InternalFailure>();
     }
     uint8_t fallbackPrefix = AddrFamily<AF_INET>::defaultPrefix;
+    auto addr = stdplus::In4Addr{};
     if (ifaddr)
     {
+        addr = ifaddr->address;
         fallbackPrefix = ifaddr->prefix;
         deleteObjectIfExists(bus, params.service, ifaddr->path);
     }
-    auto addr = address.value_or(ifaddr->address);
+    addr = address.value_or(addr);
     if (addr != stdplus::In4Addr{})
     {
         createIfAddr<AF_INET>(bus, params, addr,