]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
CID: 1211950 fix memory leak of iksparser in function nlsml_parse in mod_rayo
authorWilliam King <william.king@quentustech.com>
Wed, 7 May 2014 07:37:32 +0000 (00:37 -0700)
committerChris Rienzo <chris.rienzo@grasshopper.com>
Thu, 8 May 2014 13:52:10 +0000 (09:52 -0400)
src/mod/event_handlers/mod_rayo/nlsml.c

index b050565071cfd840888edd5f9b84a89df686a512..e166742be8db0c7675d9b3dc6ee005143742454a 100644 (file)
@@ -313,29 +313,37 @@ static int cdata_hook(void *user_data, char *data, size_t len)
 enum nlsml_match_type nlsml_parse(const char *result, const char *uuid)
 {
        struct nlsml_parser parser = { 0 };
+       int result = NMT_BAD_XML;
+       iksparser *p = NULL;
        parser.uuid = uuid;
+
        if (!zstr(result)) {
-               iksparser *p = iks_sax_new(&parser, tag_hook, cdata_hook);
+               p = iks_sax_new(&parser, tag_hook, cdata_hook);
                if (iks_parse(p, result, 0, 1) == IKS_OK) {
                        /* check result */
                        if (parser.match) {
-                               return NMT_MATCH;
+                               result = NMT_MATCH;
+                               goto end;
                        }
                        if (parser.nomatch) {
-                               return NMT_NOMATCH;
+                               result = NMT_NOMATCH;
+                               goto end;
                        }
                        if (parser.noinput) {
-                               return NMT_NOINPUT;
+                               result = NMT_NOINPUT;
+                               goto end;
                        }
                        switch_log_printf(SWITCH_CHANNEL_UUID_LOG(parser.uuid), SWITCH_LOG_INFO, "NLSML result does not have match/noinput/nomatch!\n");
                } else {
                        switch_log_printf(SWITCH_CHANNEL_UUID_LOG(parser.uuid), SWITCH_LOG_INFO, "Failed to parse NLSML!\n");
                }
-               iks_parser_delete(p);
        } else {
                switch_log_printf(SWITCH_CHANNEL_UUID_LOG(parser.uuid), SWITCH_LOG_INFO, "Missing NLSML result\n");
        }
-       return NMT_BAD_XML;
+ end:
+       if ( p )
+               iks_parser_delete(p);
+       return result;
 }
 
 #define NLSML_NS "http://www.ietf.org/xml/ns/mrcpv2"