Index: pbx/pbx_realtime.c =================================================================== --- pbx/pbx_realtime.c (revision 369969) +++ pbx/pbx_realtime.c (working copy) @@ -228,52 +228,50 @@ char exten[AST_MAX_EXTENSION]; } cache_search = { { .priority = priority, .context = (char *) context }, }; char *buf = ast_strdupa(data); - if (buf) { - /* "Realtime" prefix is stripped off in the parent engine. The - * remaining string is: [[context@]table][/opts] */ - char *opts = strchr(buf, '/'); - if (opts) - *opts++ = '\0'; - table = strchr(buf, '@'); - if (table) { - *table++ = '\0'; - ctx = buf; - } - ctx = S_OR(ctx, context); - table = S_OR(table, "extensions"); - if (!ast_strlen_zero(opts)) { - ast_app_parse_options(switch_opts, &flags, NULL, opts); - } - ast_copy_string(cache_search.exten, exten, sizeof(cache_search.exten)); - if (mode == MODE_MATCH && (ce = ao2_find(cache, &cache_search, OBJ_POINTER))) { - var = dup_vars(ce->var); + /* "Realtime" prefix is stripped off in the parent engine. The + * remaining string is: [[context@]table][/opts] */ + char *opts = strchr(buf, '/'); + if (opts) + *opts++ = '\0'; + table = strchr(buf, '@'); + if (table) { + *table++ = '\0'; + ctx = buf; + } + ctx = S_OR(ctx, context); + table = S_OR(table, "extensions"); + if (!ast_strlen_zero(opts)) { + ast_app_parse_options(switch_opts, &flags, NULL, opts); + } + ast_copy_string(cache_search.exten, exten, sizeof(cache_search.exten)); + if (mode == MODE_MATCH && (ce = ao2_find(cache, &cache_search, OBJ_POINTER))) { + var = dup_vars(ce->var); + ao2_ref(ce, -1); + } else { + var = realtime_switch_common(table, ctx, exten, priority, mode, flags); + do { + struct ast_variable *new; + /* Only cache matches */ + if (mode != MODE_MATCH) { + break; + } + if (!(new = dup_vars(var))) { + break; + } + if (!(ce = ao2_alloc(sizeof(*ce) + strlen(exten) + strlen(context), free_entry))) { + ast_variables_destroy(new); + break; + } + ce->context = ce->exten + strlen(exten) + 1; + strcpy(ce->exten, exten); /* SAFE */ + strcpy(ce->context, context); /* SAFE */ + ce->priority = priority; + ce->var = new; + ce->when = ast_tvnow(); + ao2_link(cache, ce); + pthread_kill(cleanup_thread, SIGURG); ao2_ref(ce, -1); - } else { - var = realtime_switch_common(table, ctx, exten, priority, mode, flags); - do { - struct ast_variable *new; - /* Only cache matches */ - if (mode != MODE_MATCH) { - break; - } - if (!(new = dup_vars(var))) { - break; - } - if (!(ce = ao2_alloc(sizeof(*ce) + strlen(exten) + strlen(context), free_entry))) { - ast_variables_destroy(new); - break; - } - ce->context = ce->exten + strlen(exten) + 1; - strcpy(ce->exten, exten); /* SAFE */ - strcpy(ce->context, context); /* SAFE */ - ce->priority = priority; - ce->var = new; - ce->when = ast_tvnow(); - ao2_link(cache, ce); - pthread_kill(cleanup_thread, SIGURG); - ao2_ref(ce, -1); - } while (0); - } + } while (0); } return var; } Index: pbx/pbx_dundi.c =================================================================== --- pbx/pbx_dundi.c (revision 369969) +++ pbx/pbx_dundi.c (working copy) @@ -1384,8 +1384,6 @@ struct dundi_hdr *h; unsigned char *decrypt_space; decrypt_space = alloca(srclen); - if (!decrypt_space) - return NULL; decrypt_memcpy(decrypt_space, src->encdata, srclen, src->iv, &trans->dcx); /* Setup header */ h = (struct dundi_hdr *)dst; @@ -1412,60 +1410,57 @@ unsigned char iv[16]; len = pack->datalen + pack->datalen / 100 + 42; compress_space = alloca(len); - if (compress_space) { - memset(compress_space, 0, len); - /* We care about everthing save the first 6 bytes of header */ - bytes = len; - res = compress(compress_space, &bytes, pack->data + 6, pack->datalen - 6); - if (res != Z_OK) { - ast_debug(1, "Ouch, compression failed!\n"); + memset(compress_space, 0, len); + /* We care about everthing save the first 6 bytes of header */ + bytes = len; + res = compress(compress_space, &bytes, pack->data + 6, pack->datalen - 6); + if (res != Z_OK) { + ast_debug(1, "Ouch, compression failed!\n"); + return -1; + } + memset(&ied, 0, sizeof(ied)); + /* Say who we are */ + if (!pack->h->iseqno && !pack->h->oseqno) { + /* Need the key in the first copy */ + if (!(peer = find_peer(&trans->them_eid))) return -1; - } - memset(&ied, 0, sizeof(ied)); - /* Say who we are */ - if (!pack->h->iseqno && !pack->h->oseqno) { - /* Need the key in the first copy */ - if (!(peer = find_peer(&trans->them_eid))) - return -1; - if (update_key(peer)) - return -1; - if (!peer->sentfullkey) - ast_set_flag(trans, FLAG_SENDFULLKEY); - /* Append key data */ - dundi_ie_append_eid(&ied, DUNDI_IE_EID, &trans->us_eid); - if (ast_test_flag(trans, FLAG_SENDFULLKEY)) { - dundi_ie_append_raw(&ied, DUNDI_IE_SHAREDKEY, peer->txenckey, 128); - dundi_ie_append_raw(&ied, DUNDI_IE_SIGNATURE, peer->txenckey + 128, 128); - } else { - dundi_ie_append_int(&ied, DUNDI_IE_KEYCRC32, peer->us_keycrc32); - } - /* Setup contexts */ - trans->ecx = peer->us_ecx; - trans->dcx = peer->us_dcx; - - /* We've sent the full key */ - peer->sentfullkey = 1; - } - /* Build initialization vector */ - build_iv(iv); - /* Add the field, rounded up to 16 bytes */ - dundi_ie_append_encdata(&ied, DUNDI_IE_ENCDATA, iv, NULL, ((bytes + 15) / 16) * 16); - /* Copy the data */ - if ((ied.pos + bytes) >= sizeof(ied.buf)) { - ast_log(LOG_NOTICE, "Final packet too large!\n"); + if (update_key(peer)) return -1; + if (!peer->sentfullkey) + ast_set_flag(trans, FLAG_SENDFULLKEY); + /* Append key data */ + dundi_ie_append_eid(&ied, DUNDI_IE_EID, &trans->us_eid); + if (ast_test_flag(trans, FLAG_SENDFULLKEY)) { + dundi_ie_append_raw(&ied, DUNDI_IE_SHAREDKEY, peer->txenckey, 128); + dundi_ie_append_raw(&ied, DUNDI_IE_SIGNATURE, peer->txenckey + 128, 128); + } else { + dundi_ie_append_int(&ied, DUNDI_IE_KEYCRC32, peer->us_keycrc32); } - encrypt_memcpy(ied.buf + ied.pos, compress_space, bytes, iv, &trans->ecx); - ied.pos += ((bytes + 15) / 16) * 16; - /* Reconstruct header */ - pack->datalen = sizeof(struct dundi_hdr); - pack->h->cmdresp = DUNDI_COMMAND_ENCRYPT; - pack->h->cmdflags = 0; - memcpy(pack->h->ies, ied.buf, ied.pos); - pack->datalen += ied.pos; - return 0; + /* Setup contexts */ + trans->ecx = peer->us_ecx; + trans->dcx = peer->us_dcx; + + /* We've sent the full key */ + peer->sentfullkey = 1; } - return -1; + /* Build initialization vector */ + build_iv(iv); + /* Add the field, rounded up to 16 bytes */ + dundi_ie_append_encdata(&ied, DUNDI_IE_ENCDATA, iv, NULL, ((bytes + 15) / 16) * 16); + /* Copy the data */ + if ((ied.pos + bytes) >= sizeof(ied.buf)) { + ast_log(LOG_NOTICE, "Final packet too large!\n"); + return -1; + } + encrypt_memcpy(ied.buf + ied.pos, compress_space, bytes, iv, &trans->ecx); + ied.pos += ((bytes + 15) / 16) * 16; + /* Reconstruct header */ + pack->datalen = sizeof(struct dundi_hdr); + pack->h->cmdresp = DUNDI_COMMAND_ENCRYPT; + pack->h->cmdflags = 0; + memcpy(pack->h->ies, ied.buf, ied.pos); + pack->datalen += ied.pos; + return 0; } static int check_key(struct dundi_peer *peer, unsigned char *newkey, unsigned char *newsig, uint32_t keycrc32) @@ -1583,9 +1578,6 @@ if (datalen) { bufcpy = alloca(datalen); - if (!bufcpy) { - goto return_cleanup; - } /* Make a copy for parsing */ memcpy(bufcpy, hdr->ies, datalen); ast_debug(1, "Got canonical message %d (%d), %d bytes data%s\n", cmd, hdr->oseqno, datalen, final ? " (Final)" : ""); @@ -3769,16 +3761,15 @@ if (nummaps) { maps = alloca(nummaps * sizeof(*maps)); nummaps = 0; - if (maps) { - AST_LIST_TRAVERSE(&mappings, cur, list) { - if (!strcasecmp(cur->dcontext, context)) - maps[nummaps++] = *cur; - } + AST_LIST_TRAVERSE(&mappings, cur, list) { + if (!strcasecmp(cur->dcontext, context)) + maps[nummaps++] = *cur; } } AST_LIST_UNLOCK(&peers); - if (!nummaps || !maps) + if (!nummaps) { return -1; + } ttlms = DUNDI_FLUFF_TIME + ttl * DUNDI_TTL_TIME; memset(&dr2, 0, sizeof(dr2)); memset(&dr, 0, sizeof(dr)); Index: channels/chan_jingle.c =================================================================== --- channels/chan_jingle.c (revision 369969) +++ channels/chan_jingle.c (working copy) @@ -1514,15 +1514,14 @@ if (data) { s = ast_strdupa(data); - if (s) { - sender = strsep(&s, "/"); - if (sender && (sender[0] != '\0')) - to = strsep(&s, "/"); - if (!to) { - ast_log(LOG_ERROR, "Bad arguments in Jingle Dialstring: %s\n", (char*) data); - return NULL; - } + sender = strsep(&s, "/"); + if (sender && (sender[0] != '\0')) { + to = strsep(&s, "/"); } + if (!to) { + ast_log(LOG_ERROR, "Bad arguments in Jingle Dialstring: %s\n", (char*) data); + return NULL; + } } client = find_jingle(to, sender); Index: channels/chan_sip.c =================================================================== --- channels/chan_sip.c (revision 369969) +++ channels/chan_sip.c (working copy) @@ -23381,7 +23381,8 @@ payload_size = ast_connected_line_build_data(connected_line_data, sizeof(connected_line_data), &connected_to_target, NULL); frame_size = payload_size + sizeof(*frame_payload); - if (payload_size != -1 && (frame_payload = alloca(frame_size))) { + if (payload_size != -1) { + frame_payload = alloca(frame_size); frame_payload->payload_size = payload_size; memcpy(frame_payload->payload, connected_line_data, payload_size); frame_payload->action = AST_FRAME_READ_ACTION_CONNECTED_LINE_MACRO; @@ -27587,11 +27588,6 @@ } host = ast_strdupa(v->value); - if (!host) { - ast_log(LOG_WARNING, "Unable to allocate stack space for parsing outboundproxy\n"); - continue; - } - host = ast_skip_blanks(host); sep = strchr(host, ','); if (sep) { @@ -28565,11 +28561,6 @@ } host = ast_strdupa(v->value); - if (!host) { - ast_log(LOG_WARNING, "Unable to allocate stack space for parsing outboundproxy\n"); - continue; - } - host = ast_skip_blanks(host); sep = strchr(host, ','); if (sep) { Index: channels/chan_iax2.c =================================================================== --- channels/chan_iax2.c (revision 369969) +++ channels/chan_iax2.c (working copy) @@ -3034,10 +3034,7 @@ unsigned char sum[16], buf[1024]; char *s2, *last; - if (!(s2 = alloca(strlen(s) + 100))) { - ast_log(LOG_WARNING, "Alloca failed!\n"); - return -1; - } + s2 = alloca(strlen(s) + 100); last = strrchr(s, '/'); if (last) @@ -6304,8 +6301,6 @@ int padding; unsigned char *workspace; workspace = alloca(*datalen + 32); - if (!workspace) - return -1; if (ntohs(fh->scallno) & IAX_FLAG_FULL) { struct ast_iax2_full_enc_hdr *efh = (struct ast_iax2_full_enc_hdr *)fh; if (iaxdebug) @@ -12307,9 +12302,7 @@ char *addr; char *portstr; - if (!(tmp = ast_strdupa(srcaddr))) - return -1; - + tmp = ast_strdupa(srcaddr); addr = strsep(&tmp, ":"); portstr = tmp; @@ -12769,7 +12762,7 @@ user->ha = ast_append_ha(v->name, v->value, user->ha, NULL); } else if (!strcasecmp(v->name, "setvar")) { varname = ast_strdupa(v->value); - if (varname && (varval = strchr(varname,'='))) { + if ((varval = strchr(varname, '='))) { *varval = '\0'; varval++; if((tmpvar = ast_variable_new(varname, varval, ""))) { Index: channels/chan_gtalk.c =================================================================== --- channels/chan_gtalk.c (revision 369969) +++ channels/chan_gtalk.c (working copy) @@ -1857,16 +1857,14 @@ if (data) { s = ast_strdupa(data); - if (s) { - sender = strsep(&s, "/"); - if (sender && (sender[0] != '\0')) { - to = strsep(&s, "/"); - } - if (!to) { - ast_log(LOG_ERROR, "Bad arguments in Gtalk Dialstring: %s\n", (char*) data); - return NULL; - } + sender = strsep(&s, "/"); + if (sender && (sender[0] != '\0')) { + to = strsep(&s, "/"); } + if (!to) { + ast_log(LOG_ERROR, "Bad arguments in Gtalk Dialstring: %s\n", (char*) data); + return NULL; + } } client = find_gtalk(to, sender); Index: apps/app_meetme.c =================================================================== --- apps/app_meetme.c (revision 369969) +++ apps/app_meetme.c (working copy) @@ -4110,8 +4110,7 @@ return -1; } - if (!(localdata = ast_strdupa(data))) - return -1; + localdata = ast_strdupa(data); AST_STANDARD_APP_ARGS(args, localdata); Index: apps/app_minivm.c =================================================================== --- apps/app_minivm.c (revision 369969) +++ apps/app_minivm.c (working copy) @@ -2054,10 +2054,6 @@ return -1; } tmpptr = ast_strdupa((char *)data); - if (!tmpptr) { - ast_log(LOG_ERROR, "Out of memory\n"); - return -1; - } argc = ast_app_separate_args(tmpptr, ',', argv, ARRAY_LEN(argv)); if (argc < 4) { ast_log(LOG_ERROR, "%d arguments passed to MiniVM_MWI, need 4.\n", argc); @@ -2102,10 +2098,6 @@ return -1; } tmpptr = ast_strdupa((char *)data); - if (!tmpptr) { - ast_log(LOG_ERROR, "Out of memory\n"); - return -1; - } argc = ast_app_separate_args(tmpptr, ',', argv, ARRAY_LEN(argv)); if (argc == 2 && !ast_strlen_zero(argv[1])) @@ -2186,10 +2178,6 @@ return -1; } tmp = ast_strdupa((char *)data); - if (!tmp) { - ast_log(LOG_ERROR, "Out of memory\n"); - return -1; - } argc = ast_app_separate_args(tmp, ',', argv, ARRAY_LEN(argv)); if (argc == 2) { if (ast_app_parse_options(minivm_app_options, &flags, opts, argv[1])) { @@ -2249,10 +2237,6 @@ return -1; } tmpptr = ast_strdupa((char *)data); - if (!tmpptr) { - ast_log(LOG_ERROR, "Out of memory\n"); - return -1; - } argc = ast_app_separate_args(tmpptr, ',', argv, ARRAY_LEN(argv)); if (argc == 2) { @@ -2476,14 +2460,9 @@ if (ast_strlen_zero(data)) { ast_log(LOG_ERROR, "MinivmAccmess needs at least two arguments: account and option\n"); error = TRUE; - } else + } else { tmpptr = ast_strdupa((char *)data); - if (!error) { - if (!tmpptr) { - ast_log(LOG_ERROR, "Out of memory\n"); - error = TRUE; - } else - argc = ast_app_separate_args(tmpptr, ',', argv, ARRAY_LEN(argv)); + argc = ast_app_separate_args(tmpptr, ',', argv, ARRAY_LEN(argv)); } if (argc <=1) { @@ -2623,7 +2602,7 @@ char *varname = ast_strdupa(var->value); struct ast_variable *tmpvar; - if (varname && (varval = strchr(varname, '='))) { + if ((varval = strchr(varname, '='))) { *varval = '\0'; varval++; if ((tmpvar = ast_variable_new(varname, varval, ""))) { @@ -2681,11 +2660,6 @@ return 0; msg_format = ast_strdupa(config); - if (msg_format == NULL) { - ast_log(LOG_WARNING, "Out of memory.\n"); - ast_free(newzone); - return 0; - } timezone_str = strsep(&msg_format, "|"); if (!msg_format) { @@ -3201,10 +3175,7 @@ struct minivm_account *vmu; char *username, *domain, *colname; - if (!(username = ast_strdupa(data))) { - ast_log(LOG_ERROR, "Memory Error!\n"); - return -1; - } + username = ast_strdupa(data); if ((colname = strchr(username, ':'))) { *colname = '\0'; @@ -3355,10 +3326,8 @@ *buf = '\0'; - if (!(username = ast_strdupa(data))) { /* Copy indata to local buffer */ - ast_log(LOG_WARNING, "Memory error!\n"); - return -1; - } + username = ast_strdupa(data); + if ((countername = strchr(username, ':'))) { *countername = '\0'; countername++; @@ -3414,10 +3383,7 @@ return -1; change = atoi(value); - if (!(username = ast_strdupa(data))) { /* Copy indata to local buffer */ - ast_log(LOG_WARNING, "Memory error!\n"); - return -1; - } + username = ast_strdupa(data); if ((countername = strchr(username, ':'))) { *countername = '\0'; Index: apps/app_macro.c =================================================================== --- apps/app_macro.c (revision 369969) +++ apps/app_macro.c (working copy) @@ -596,8 +596,7 @@ char *expr = NULL, *label_a = NULL, *label_b = NULL; int res = 0; - if (!(expr = ast_strdupa(data))) - return -1; + expr = ast_strdupa(data); if ((label_a = strchr(expr, '?'))) { *label_a = '\0'; Index: apps/app_osplookup.c =================================================================== --- apps/app_osplookup.c (revision 369969) +++ apps/app_osplookup.c (working copy) @@ -2240,10 +2240,7 @@ AST_APP_ARG(options); ); - if (!(tmp = ast_strdupa(data))) { - ast_log(LOG_ERROR, "Out of memory\n"); - return OSP_AST_ERROR; - } + tmp = ast_strdupa(data); AST_STANDARD_APP_ARGS(args, tmp); @@ -2335,10 +2332,7 @@ return OSP_AST_ERROR; } - if (!(tmp = ast_strdupa(data))) { - ast_log(LOG_ERROR, "Out of memory\n"); - return OSP_AST_ERROR; - } + tmp = ast_strdupa(data); AST_STANDARD_APP_ARGS(args, tmp); @@ -2609,10 +2603,7 @@ return OSP_AST_ERROR; } - if (!(tmp = ast_strdupa(data))) { - ast_log(LOG_ERROR, "Out of memory\n"); - return OSP_AST_ERROR; - } + tmp = ast_strdupa(data); AST_STANDARD_APP_ARGS(args, tmp); @@ -2791,10 +2782,7 @@ AST_APP_ARG(options); ); - if (!(tmp = ast_strdupa(data))) { - ast_log(LOG_ERROR, "Out of memory\n"); - return OSP_AST_ERROR; - } + tmp = ast_strdupa(data); AST_STANDARD_APP_ARGS(args, tmp); Index: addons/res_config_mysql.c =================================================================== --- addons/res_config_mysql.c (revision 369969) +++ addons/res_config_mysql.c (working copy) @@ -467,7 +467,7 @@ } initfield = ast_strdupa(newparam); - if (initfield && (op = strchr(initfield, ' '))) { + if ((op = strchr(initfield, ' '))) { *op = '\0'; } Index: funcs/func_strings.c =================================================================== --- funcs/func_strings.c (revision 369969) +++ funcs/func_strings.c (working copy) @@ -919,9 +919,10 @@ char *origvar = "", *value2, varname[256]; int i, ishash = 0; + if (!var) { + return -1; + } value2 = ast_strdupa(value); - if (!var || !value2) - return -1; if (!strcmp(cmd, "HASH")) { const char *var2 = pbx_builtin_getvar_helper(chan, "~ODBCFIELDS~"); Index: funcs/func_logic.c =================================================================== --- funcs/func_logic.c (revision 369969) +++ funcs/func_logic.c (working copy) @@ -251,16 +251,14 @@ if ((chan2 = ast_channel_get_by_name(args.channel))) { char *s = alloca(strlen(args.varname) + 4); - if (s) { - sprintf(s, "${%s}", args.varname); - ast_channel_lock(chan2); - if (buf) { - pbx_substitute_variables_helper(chan2, s, buf, len); - } else { - ast_str_substitute_variables(str, len, chan2, s); - } - ast_channel_unlock(chan2); + sprintf(s, "${%s}", args.varname); + ast_channel_lock(chan2); + if (buf) { + pbx_substitute_variables_helper(chan2, s, buf, len); + } else { + ast_str_substitute_variables(str, len, chan2, s); } + ast_channel_unlock(chan2); chan2 = ast_channel_unref(chan2); } } Index: funcs/func_cut.c =================================================================== --- funcs/func_cut.c (revision 369969) +++ funcs/func_cut.c (working copy) @@ -170,9 +170,8 @@ /* Check arguments */ if (args.argc < 3) { return ERROR_NOARG; - } else if (!(var_expr = alloca(strlen(args.varname) + 4))) { - return ERROR_NOMEM; } + var_expr = alloca(strlen(args.varname) + 4); /* Get the value of the variable named in the 1st argument */ snprintf(var_expr, strlen(args.varname) + 4, "${%s}", args.varname); Index: main/http.c =================================================================== --- main/http.c (revision 369969) +++ main/http.c (working copy) @@ -643,9 +643,7 @@ return NULL; } - if (!(buf = alloca(content_length))) { - return NULL; - } + buf = alloca(content_length); if (!fgets(buf, content_length, ser->f)) { return NULL; } Index: main/strcompat.c =================================================================== --- main/strcompat.c (revision 369969) +++ main/strcompat.c (working copy) @@ -68,12 +68,12 @@ unsigned char *buf; int buflen; - buflen = strlen(name) + strlen(value) + 2; - buf = alloca(buflen); - if (!overwrite && getenv(name)) return 0; + buflen = strlen(name) + strlen(value) + 2; + buf = alloca(buflen); + snprintf(buf, buflen, "%s=%s", name, value); return putenv(buf); @@ -105,23 +105,19 @@ char *strcasestr(const char *haystack, const char *needle) { char *u1, *u2; + char *offset; int u1len = strlen(haystack) + 1, u2len = strlen(needle) + 1; + if (u2len > u1len) { + /* Needle bigger than haystack */ + return NULL; + } u1 = alloca(u1len); u2 = alloca(u2len); - if (u1 && u2) { - char *offset; - if (u2len > u1len) { - /* Needle bigger than haystack */ - return NULL; - } - offset = strstr(upper(haystack, u1, u1len), upper(needle, u2, u2len)); - if (offset) { - /* Return the offset into the original string */ - return ((char *)((unsigned long)haystack + (unsigned long)(offset - u1))); - } else { - return NULL; - } + offset = strstr(upper(haystack, u1, u1len), upper(needle, u2, u2len)); + if (offset) { + /* Return the offset into the original string */ + return ((char *)((unsigned long)haystack + (unsigned long)(offset - u1))); } else { return NULL; } Index: main/pbx.c =================================================================== --- main/pbx.c (revision 369969) +++ main/pbx.c (working copy) @@ -10120,10 +10120,8 @@ struct ast_channel *chan2 = ast_channel_get_by_name(channel); if (chan2) { char *s = alloca(strlen(value) + 4); - if (s) { - sprintf(s, "${%s}", value); - pbx_substitute_variables_helper(chan2, s, tmp, sizeof(tmp) - 1); - } + sprintf(s, "${%s}", value); + pbx_substitute_variables_helper(chan2, s, tmp, sizeof(tmp) - 1); chan2 = ast_channel_unref(chan2); } pbx_builtin_setvar_helper(chan, name, tmp); Index: main/file.c =================================================================== --- main/file.c (revision 369969) +++ main/file.c (working copy) @@ -658,8 +658,6 @@ preflang = ""; buflen = strlen(preflang) + strlen(filename) + 4; buf = alloca(buflen); - if (buf == NULL) - return NULL; fmts = fileexists_core(filename, NULL, preflang, buf, buflen); if (fmts > 0) fmts &= AST_FORMAT_AUDIO_MASK; @@ -692,8 +690,6 @@ preflang = ""; buflen = strlen(preflang) + strlen(filename) + 4; buf = alloca(buflen); - if (buf == NULL) - return NULL; for (format = AST_FORMAT_FIRST_VIDEO_BIT; format <= AST_FORMAT_VIDEO_MASK; format = format << 1) { int fd; @@ -928,8 +924,6 @@ preflang = ""; buflen = strlen(preflang) + strlen(filename) + 4; /* room for everything */ buf = alloca(buflen); - if (buf == NULL) - return 0; return fileexists_core(filename, fmt, preflang, buf, buflen); } Index: res/res_agi.c =================================================================== --- res/res_agi.c (revision 369969) +++ res/res_agi.c (working copy) @@ -1554,10 +1554,11 @@ unsigned short srvport; /* format of agiurl is "hagi://host.domain[:port][/script/name]" */ - if (!(host = ast_strdupa(agiurl + 7))) { /* Remove hagi:// */ + if (strlen(agiurl) < 7) { /* Remove hagi:// */ ast_log(LOG_WARNING, "An error occurred parsing the AGI URI: %s", agiurl); return AGI_RESULT_FAILURE; } + host = ast_strdupa(agiurl + 7); /* Strip off any script name */ if ((script = strchr(host, '/'))) {