Hi!

I was porting diff.c to Emscripten
(https://github.com/emscripten-core/emscripten/issues/13106) and it
was crashing because Emscripten does not allocate argv as a single
chunk.

diff.c computes an argument length by subtracting (i+1)-th and i-th
arguments' pointers. This is incorrect if argv are not allocated as a
contiguous chunk without gaps.

Offending line:
https://github.com/openbsd/src/blob/master/usr.bin/diff/diff.c#L276

StackOverflow suggests that relying on this is not POSIX/C-standard:
https://stackoverflow.com/questions/24765640/are-the-elements-of-the-argv-array-always-contiguous-in-memory

Thanks!
-- 
Vadim Kantorov

Reply via email to