Skip to content

Commit 574c1a9

Browse files
author
Chandra Pratap
committed
common/test: Add a test to trigger the undefined behaviour
Add a test that reproduces the UB when the fix is not applied.
1 parent 667fff3 commit 574c1a9

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

common/test/run-tlv_span.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,13 @@ int main(int argc, char *argv[])
131131
len = tlv_span(wire, 0, 1, &start);
132132
assert(start == 0);
133133
assert(len == strlen("0010b8538094dbd70d8a0f0439d8e64f766f") / 2);
134+
135+
/* Simulate an empty tlvstream */
136+
wire = tal_arr(tmpctx, u8, 0);
137+
len = tlv_span(wire, 0, UINT64_MAX, &start);
138+
assert(start == 0);
139+
assert(len == 0);
140+
134141
common_shutdown();
135142
return 0;
136143
}

0 commit comments

Comments
 (0)