]> git.ozlabs.org Git - ccan/commitdiff
opt: fix opt_unregister.
authorRusty Russell <rusty@rustcorp.com.au>
Tue, 11 Feb 2020 04:09:43 +0000 (14:39 +1030)
committerRusty Russell <rusty@rustcorp.com.au>
Tue, 11 Feb 2020 04:09:43 +0000 (14:39 +1030)
Instead of memmoving N structs, we were memmoving N bytes.

But why did the test pass then?  It was doing memmove(..., 1)
instead of memmove(..., sizeof(struct opt_table)!

Because the two structures were really similar; the main difference
was the first entry, which points to the name.  But they were allocated
consecutively, and Intel being little-endian, the only difference was
the first byte!  Thus memmove(1) was enough to make it "work".

Change two options in the test to be sufficiently different, and
the bug shows up.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>

No differences found