@@ -237,8 +237,10 @@ ipx_plugin_init(ipx_ctx_t *ctx, const char *params)
237237 free (cleaned_urtemplate );
238238 ipx_plugin_destroy (ctx , conf );
239239 free_IPFIX2UR_map (map );
240- free (conf -> ur_message );
241- free (conf );
240+ if (conf != NULL ) {
241+ free (conf -> ur_message );
242+ free (conf );
243+ }
242244 return IPX_ERR_DENIED ;
243245}
244246
@@ -293,26 +295,8 @@ ipx_plugin_destroy(ipx_ctx_t *ctx, void *cfg)
293295{
294296 (void ) ctx ;
295297 struct conf_unirec * conf = (struct conf_unirec * ) cfg ;
296- if (conf == NULL ) {
297- IPX_CTX_ERROR (ctx , "configuration is NULL! Skipping ipx_plugin_destroy()" );
298- }
299-
300298 IPX_CTX_INFO (ctx , "UniRec plugin finalization." );
301299
302- trap_ctx_terminate (conf -> tctx );
303-
304- // Destroy a translator and a record
305- translator_destroy (conf -> translator );
306-
307- // Destroy parsed XML configuration
308- configuration_free (conf -> params );
309-
310- trap_ctx_finalize (& conf -> tctx );
311-
312- ur_free_template (conf -> urtmpl );
313-
314- free (conf -> ur_message );
315-
316300 if (pthread_mutex_lock (& urp_mutex ) == -1 ) {
317301 IPX_CTX_ERROR (ctx , "Could not lock. (%s:%d)" , __FILE__ , __LINE__ );
318302 }
@@ -324,7 +308,23 @@ ipx_plugin_destroy(ipx_ctx_t *ctx, void *cfg)
324308 if (pthread_mutex_unlock (& urp_mutex ) == -1 ) {
325309 IPX_CTX_ERROR (ctx , "Could not unlock. (%s:%d)" , __FILE__ , __LINE__ );
326310 }
327- // Destroy instance structure
328- free (conf );
311+
312+ if (conf != NULL ) {
313+ trap_ctx_terminate (conf -> tctx );
314+ // Destroy a translator and a record
315+ translator_destroy (conf -> translator );
316+
317+ // Destroy parsed XML configuration
318+ configuration_free (conf -> params );
319+
320+ trap_ctx_finalize (& conf -> tctx );
321+
322+ ur_free_template (conf -> urtmpl );
323+
324+ free (conf -> ur_message );
325+
326+ // Destroy instance structure
327+ free (conf );
328+ }
329329}
330330
0 commit comments