Null CFGBlock successors

Hi,

I am writing a ClangTool that visits every function in a module, and edits source code based on the CFG. For a function I want to instrument, however, the CFG produces blocks that list a successor as NULL. This is a problem because I need to perform a breadth-first search of the CFG, and I cannot because of the null successor. I have listed the result of cfg->dump() below. What could be the cause of this? Any help would be appreciated. Thanks.

[B18 (ENTRY)]
Succs (1): B17

[B1]
1: i += 30
Preds (1): B2
Succs (1): B5

[B2]
1: strlen(json)
2: MarsSendBlocking(1, json, [B2.1])
Preds (2): B3 B4
Succs (1): B1

[B3]
Preds (1): B4
Succs (1): B2

[B4]
T: if
Preds (1): B5
Succs (2): B3 B2

[B5]
T: for (; ; …)
Preds (2): B1 B6
Succs (2): B4 NULL

[B6]
1: strlen(json)
2: MarsSendBlocking(1, json, [B6.1])
Succs (1): B5

[B7]
1: i++
Preds (2): B8 B9
Succs (1): B10

[B8]
Preds (1): B9
Succs (1): B7

[B9]
1: char tempString[6];
T: if
Preds (1): B10
Succs (2): B8 B7

[B10]
T: for (…; ; …)
Preds (2): B7 B11
Succs (2): B9 NULL

[B11]
1: ndc_str[14] = 0
2: npi_str[12] = 0
3: zip_str[5] = 0
4: t.tm_isdst = -1
5: mktime(&t)
6: time_prescribed = [B11.5]
7: printf(“year:%u month:%u day:%u hour:%u min:%u sec:%u\n”, t.tm_year, t.tm_mon, t.tm_mday, t.tm_hour, t.tm_min, t.tm_sec)
8: i = 0
Preds (1): B12
Succs (1): B10

[B12]
T: if
Preds (2): B13 B14
Succs (2): B11 B0

[B13]
Preds (1): B14
Succs (1): B12

[B14]
T: if
Succs (2): B13 B12

[B15]
1: i++
Preds (1): B16
Succs (1): B16

[B16]
T: for (…; ; …)
Preds (2): B15 B17
Succs (2): B15 NULL

[B17]
1: char ndc_str[15];
2: char npi_str[13];
3: char zip_str[6];
4: char dosageIntervals;
5: int last_msg_idx;
6: int i;
7: struct tm t;
8: time_t time_prescribed;
9: i = 0
Preds (1): B18
Succs (1): B16

[B0 (EXIT)]
Preds (1): B12