diff --git a/channels/chan_sip.c b/channels/chan_sip.c
index 3bec6f8708a56f37ecc7afe0646ce8bf842b1533..9b32f264713a0c7a55c354c8126af84676ccc2c6 100644
--- a/channels/chan_sip.c
+++ b/channels/chan_sip.c
@@ -22281,10 +22281,10 @@ static int sip_addheader(struct ast_channel *chan, void *data)
 	/* Check for headers */
 	while (!ok && no <= 50) {
 		no++;
-		snprintf(varbuf, sizeof(varbuf), "_SIPADDHEADER%.2d", no);
+		snprintf(varbuf, sizeof(varbuf), "__SIPADDHEADER%.2d", no);
 
-		/* Compare without the leading underscore */
-		if( (pbx_builtin_getvar_helper(chan, (const char *) varbuf + 1) == (const char *) NULL) )
+		/* Compare without the leading underscores */
+		if( (pbx_builtin_getvar_helper(chan, (const char *) varbuf + 2) == (const char *) NULL) )
 			ok = TRUE;
 	}
 	if (ok) {