res_parking: Fix crash if ATTENDEDTRANSFER set empty before Park.
authorRichard Mudgett <rmudgett@digium.com>
Tue, 14 Jul 2015 19:36:42 +0000 (14:36 -0500)
committerRichard Mudgett <rmudgett@digium.com>
Thu, 16 Jul 2015 17:24:51 +0000 (12:24 -0500)
setup_park_common_datastore() was assuming that a non-NULL string returned
for the ATTENDEDTRANSFER and BLINDTRANSFER channel variables are not empty
strings.  Things got crashy as a result.

* Made setup_park_common_datastore() treat the channel variable values the
same whether they are NULL or empty for ATTENDEDTRANSFER and
BLINDTRANSFER.

ASTERISK-25254 #close
Reported by: Richard Mudgett

Change-Id: I9a9c174b33f354f35f82cc6b7cea8303adbaf9c2

res/parking/parking_applications.c

index 5077474..7ce8a32 100644 (file)
@@ -349,8 +349,12 @@ static int setup_park_common_datastore(struct ast_channel *parkee, const char *p
        attended_transfer = pbx_builtin_getvar_helper(parkee, "ATTENDEDTRANSFER");
        blind_transfer = pbx_builtin_getvar_helper(parkee, "BLINDTRANSFER");
 
-       if (attended_transfer || blind_transfer) {
-               parker_dial_string = ast_strdupa(S_OR(attended_transfer, blind_transfer));
+       if (!ast_strlen_zero(attended_transfer)) {
+               parker_dial_string = ast_strdupa(attended_transfer);
+       } else if (!ast_strlen_zero(blind_transfer)) {
+               parker_dial_string = ast_strdupa(blind_transfer);
+               /* Ensure that attended_transfer is NULL and not an empty string. */
+               attended_transfer = NULL;
        }
 
        ast_channel_unlock(parkee);