Lock around variables retrieved, and copy the values, if they stay persistent,
[asterisk/asterisk.git] / apps / app_morsecode.c
index 6c88ed3..455ee04 100644 (file)
@@ -111,16 +111,20 @@ static int morsecode_exec(struct ast_channel *chan, void *data)
        }
 
        /* Use variable MORESEDITLEN, if set (else 80) */
+       ast_channel_lock(chan);
        ditlenc = pbx_builtin_getvar_helper(chan, "MORSEDITLEN");
        if (ast_strlen_zero(ditlenc) || (sscanf(ditlenc, "%d", &ditlen) != 1)) {
                ditlen = 80;
        }
+       ast_channel_unlock(chan);
 
        /* Use variable MORSETONE, if set (else 800) */
+       ast_channel_lock(chan);
        tonec = pbx_builtin_getvar_helper(chan, "MORSETONE");
        if (ast_strlen_zero(tonec) || (sscanf(tonec, "%d", &tone) != 1)) {
                tone = 800;
        }
+       ast_channel_unlock(chan);
 
        for (digit = data; *digit; digit++) {
                int digit2 = *digit;