diff --git a/epan/dissectors/packet-ber.c b/epan/dissectors/packet-ber.c
index 7dcfd42..adf01bd 100644
--- a/epan/dissectors/packet-ber.c
+++ b/epan/dissectors/packet-ber.c
@@ -3503,6 +3503,10 @@ printf("CHOICE dissect_ber_old_choice(%s) entered len:%d\n", name, tvb_length_re
#endif
start_offset = offset;
+ if (branch_taken) {
+ *branch_taken = -1;
+ }
+
if (tvb_length_remaining(tvb, offset) == 0) {
item = proto_tree_add_string_format(
parent_tree, hf_ber_error, tvb, offset, 0, "empty_choice",
@@ -3545,9 +3549,6 @@ printf("CHOICE dissect_ber_old_choice(%s) entered len:%d\n", name, tvb_length_re
/* loop over all entries until we find the right choice or
run out of entries */
ch = choice;
- if (branch_taken) {
- *branch_taken = -1;
- }
first_pass = TRUE;
while (ch->func || first_pass) {
if (branch_taken) {