WebAssembly / component-model

Repository for design and specification of the Component Model
Other
945 stars 79 forks source link

ABI Assuming realloc to a smaller len will truncate existing alloc #329

Closed GordonSmith closed 6 months ago

GordonSmith commented 6 months ago

This is not true for c++ guests (although it can be a common optimization in some clibs - but less likely on embedded systems etc.)

lukewagner commented 6 months ago

I'm afraid I don't follow: realloc() is generally specified to preserve the original contents of the incoming buffer. realloc() can of course return a different pointer than is passed as parameter (in which case the impl will have to copy over the original contents over to the returned buffer), but all 5 locations you linked to anticipate this by updating ptr with the return value of cx.opts.realloc(), so I don't see the problem.