From 8905f9054e57aa7e86e35ec64e9705cbc1401bf7 Mon Sep 17 00:00:00 2001
From: Amna <amna.snene@savoirfairelinux.com>
Date: Tue, 10 Sep 2024 17:35:15 -0400
Subject: [PATCH] upnp: enforce available mappings limits only if there is a
 valid IGD.

GitLab: #44
Change-Id: I30ff7177fc9a4a5afbfb6dcd394892792b174e56
---
 src/upnp/upnp_context.cpp | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/src/upnp/upnp_context.cpp b/src/upnp/upnp_context.cpp
index 777f459..cf9b6ed 100644
--- a/src/upnp/upnp_context.cpp
+++ b/src/upnp/upnp_context.cpp
@@ -617,6 +617,10 @@ UPnPContext::getCurrentIgd() const
 void
 UPnPContext::enforceAvailableMappingsLimits()
 {
+    // If there is no valid IGD, do nothing.
+    if (!isReady())
+        return;
+        
     for (auto type : {PortType::TCP, PortType::UDP}) {
         int pendingCount = 0;
         int inProgressCount = 0;
-- 
GitLab