]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
[mod_say_*] fix possible memory-leak in say_ip() 790/head
authorLin.Sun <lin.sun@zoom.us>
Thu, 13 Aug 2020 02:50:13 +0000 (10:50 +0800)
committerLin.Sun <lin.sun@zoom.us>
Tue, 18 Aug 2020 06:53:02 +0000 (14:53 +0800)
src/mod/say/mod_say_en/mod_say_en.c
src/mod/say/mod_say_es_ar/mod_say_es_ar.c
src/mod/say/mod_say_he/mod_say_he.c
src/mod/say/mod_say_sv/mod_say_sv.c

index 520aa728a0ff47d90f92021733bdd17fc3cdcfc9..5ea52357ddc78482f8888277164d62bf8154351d 100644 (file)
@@ -67,6 +67,18 @@ SWITCH_MODULE_DEFINITION(mod_say_en, mod_say_en_load, NULL, NULL);
                say_args->method = smeth; say_args->type = stype;                               \
        }                                                                                                                                       \
 
+#define say_num_goto_status(_sh, num, meth, tag) {                                             \
+               char tmp[80];                                                                                                   \
+               switch_status_t tstatus;                                                                                \
+               switch_say_args_t tsay_args = *say_args;                                                \
+               tsay_args.type = SST_ITEMS;                                                                             \
+               tsay_args.method = meth;                                                                                \
+               switch_snprintf(tmp, sizeof(tmp), "%u", (unsigned)num);                 \
+               if ((tstatus = en_say_general_count(_sh, tmp, &tsay_args)) !=   \
+                       SWITCH_STATUS_SUCCESS) {                                                                        \
+                       switch_goto_status(tstatus, tag);                                                       \
+               }                                                                                                                               \
+       }
 
 
 static switch_status_t play_group(switch_say_method_t method, int a, int b, int c, char *what, switch_say_file_handle_t *sh)
@@ -527,13 +539,13 @@ static switch_status_t say_ip(switch_say_file_handle_t *sh,
 
        *d++ = '\0';
 
-       say_num(sh, atoi(a), say_args->method);
+       say_num_goto_status(sh, atoi(a), say_args->method, end);
        switch_say_file(sh, "digits/dot");
-       say_num(sh, atoi(b), say_args->method);
+       say_num_goto_status(sh, atoi(b), say_args->method, end);
        switch_say_file(sh, "digits/dot");
-       say_num(sh, atoi(c), say_args->method);
+       say_num_goto_status(sh, atoi(c), say_args->method, end);
        switch_say_file(sh, "digits/dot");
-       say_num(sh, atoi(d), say_args->method);
+       say_num_goto_status(sh, atoi(d), say_args->method, end);
 
  end:
 
index 390d69d6bccab52dd254821b1561f7215acf6bfe..9a23738968cfbd9610f07eed883a8c1544fe4fbe 100644 (file)
@@ -69,6 +69,18 @@ SWITCH_MODULE_DEFINITION(mod_say_es_ar, mod_say_es_ar_load, NULL, NULL);
                say_args->method = smeth; say_args->type = stype;                               \
        }                                                                                                                                       \
 
+#define say_num_goto_status(_sh, num, meth, tag) {                                             \
+               char tmp[80];                                                                                                   \
+               switch_status_t tstatus;                                                                                \
+               switch_say_args_t tsay_args = *say_args;                                                \
+               tsay_args.type = SST_ITEMS;                                                                             \
+               tsay_args.method = meth;                                                                                \
+               switch_snprintf(tmp, sizeof(tmp), "%u", (unsigned)num);                 \
+               if ((tstatus = es_say_general_count(_sh, tmp, &tsay_args)) !=   \
+                       SWITCH_STATUS_SUCCESS) {                                                                        \
+                       switch_goto_status(tstatus, tag);                                                       \
+               }                                                                                                                               \
+       }
 
 
 static switch_status_t play_group(switch_say_method_t method, switch_say_gender_t gender, int a, int b, int c, char *what, switch_say_file_handle_t *sh)
@@ -523,13 +535,13 @@ static switch_status_t say_ip(switch_say_file_handle_t *sh,
 
        *d++ = '\0';
 
-       say_num(sh, atoi(a), say_args->method);
+       say_num_goto_status(sh, atoi(a), say_args->method, end);
        switch_say_file(sh, "digits/dot");
-       say_num(sh, atoi(b), say_args->method);
+       say_num_goto_status(sh, atoi(b), say_args->method, end);
        switch_say_file(sh, "digits/dot");
-       say_num(sh, atoi(c), say_args->method);
+       say_num_goto_status(sh, atoi(c), say_args->method, end);
        switch_say_file(sh, "digits/dot");
-       say_num(sh, atoi(d), say_args->method);
+       say_num_goto_status(sh, atoi(d), say_args->method, end);
 
  end:
 
index 27f9f2d70f3ef0598606a3a48350873944c2bf35..68971cf55dfb8c6d6224c613b53d3a52b5e95448 100644 (file)
@@ -67,6 +67,19 @@ SWITCH_MODULE_DEFINITION(mod_say_he, mod_say_he_load, NULL, NULL);
                say_args->method = smeth; say_args->type = stype;                               \
        }                                                                                                                                       \
 
+#define say_num_goto_status(_sh, num, meth, tag) {                                             \
+               char tmp[80];                                                                                                   \
+               switch_status_t tstatus;                                                                                \
+               switch_say_args_t tsay_args = *say_args;                                                \
+               tsay_args.type = SST_ITEMS;                                                                             \
+               tsay_args.method = meth;                                                                                \
+               switch_snprintf(tmp, sizeof(tmp), "%u", (unsigned)num);                 \
+               if ((tstatus = he_say_general_count(_sh, tmp, &tsay_args)) !=   \
+                       SWITCH_STATUS_SUCCESS) {                                                                        \
+                       switch_goto_status(tstatus, tag);                                                       \
+               }                                                                                                                               \
+       }
+
 
 typedef enum {
        PGR_HUNDREDS = 1000,
@@ -691,13 +704,13 @@ static switch_status_t say_ip(switch_say_file_handle_t *sh,
 
        *d++ = '\0';
 
-       say_num(sh, atoi(a), say_args->method);
+       say_num_goto_status(sh, atoi(a), say_args->method, end);
        switch_say_file(sh, "digits/dot");
-       say_num(sh, atoi(b), say_args->method);
+       say_num_goto_status(sh, atoi(b), say_args->method, end);
        switch_say_file(sh, "digits/dot");
-       say_num(sh, atoi(c), say_args->method);
+       say_num_goto_status(sh, atoi(c), say_args->method, end);
        switch_say_file(sh, "digits/dot");
-       say_num(sh, atoi(d), say_args->method);
+       say_num_goto_status(sh, atoi(d), say_args->method, end);
 
  end:
 
index 7a2311b013ef3dae5d9e7604d00f0703addc2242..d495ac91f3e6b8da47003691c7151f331b6cb395 100644 (file)
@@ -67,7 +67,21 @@ SWITCH_MODULE_DEFINITION(mod_say_sv, mod_say_sv_load, NULL, NULL);
                        return tstatus;                                                         \
                }                                                                               \
                say_args->method = smeth; say_args->type = stype;                               \
-       }                                                                                       \
+       }                                                                                                                                       \
+
+#define say_num_goto_status(_sh, num, meth, tag) {                                             \
+               char tmp[80];                                                                                                   \
+               switch_status_t tstatus;                                                                                \
+               switch_say_args_t tsay_args = *say_args;                                                \
+               tsay_args.type = SST_ITEMS;                                                                             \
+               tsay_args.method = meth;                                                                                \
+               switch_snprintf(tmp, sizeof(tmp), "%u", (unsigned)num);                 \
+               if ((tstatus = sv_say_general_count(_sh, tmp, &tsay_args)) !=   \
+                       SWITCH_STATUS_SUCCESS) {                                                                        \
+                       switch_goto_status(tstatus, tag);                                                       \
+               }                                                                                                                               \
+       }
+
 
 static switch_status_t play_group(switch_say_method_t method, switch_say_gender_t gender, int a, int b, int c, char *what, switch_say_file_handle_t *sh)
 {
@@ -532,13 +546,13 @@ static switch_status_t say_ip(switch_say_file_handle_t *sh, char *tosay, switch_
 
         *d++ = '\0';
 
-        say_num(sh, atoi(a), say_args->method);
+        say_num_goto_status(sh, atoi(a), say_args->method, end);
         switch_say_file(sh, "digits/punkt");
-        say_num(sh, atoi(b), say_args->method);
+        say_num_goto_status(sh, atoi(b), say_args->method, end);
         switch_say_file(sh, "digits/punkt");
-        say_num(sh, atoi(c), say_args->method);
+        say_num_goto_status(sh, atoi(c), say_args->method, end);
         switch_say_file(sh, "digits/punkt");
-        say_num(sh, atoi(d), say_args->method);
+        say_num_goto_status(sh, atoi(d), say_args->method, end);
 
  end: