--- ../asterisk-13.13.0_mod/main/srv.c 2016-11-23 16:26:01.000000000 +0100 +++ main/srv.c 2017-02-07 13:34:43.000000000 +0100 @@ -222,6 +222,14 @@ } (*context)->prev = AST_LIST_FIRST(&(*context)->entries); + + if ((*context)->num_records==0) { + ast_log(LOG_ERROR,"no records in srv_lookup context\n"); + ast_free(*context); + *context = NULL; + return -1; + } + *host = (*context)->prev->host; *port = (*context)->prev->port; AST_LIST_TRAVERSE(&(*context)->entries, cur, list) {