agent: Avoid leak on programming error
authorOlivier Crête <olivier.crete@collabora.com>
Mon, 3 May 2021 21:01:59 +0000 (17:01 -0400)
committerOlivier Crête <olivier.crete@collabora.com>
Mon, 3 May 2021 22:42:43 +0000 (18:42 -0400)
Even if the agent is invalid, don't leak.

This makes coverity a little happier.

agent/agent.c

index a510be5..75e2275 100644 (file)
@@ -6676,11 +6676,13 @@ _generate_stream_sdp (NiceAgent *agent, NiceStream *stream,
 NICEAPI_EXPORT gchar *
 nice_agent_generate_local_sdp (NiceAgent *agent)
 {
-  GString * sdp = g_string_new (NULL);
+  GString *sdp;
   GSList *i;
 
   g_return_val_if_fail (NICE_IS_AGENT (agent), NULL);
 
+  sdp = g_string_new (NULL);
+
   agent_lock (agent);
 
   for (i = agent->streams; i; i = i->next) {