Avoid UB in FixedSizeSignature
The initial implementation of {FixedSizeSignature} contains undefined behaviour, because {InitReps} wrote to the {reps_} array before the constructor of that array has been called. This also resulted in bugs if {FixedSizeSignature} was used with types that actually have a constructor (like {ValueType}). The array constructor would call the default constructor on each contained element, thus overwriting the values written by {InitReps}. This CL fixes that by switching to a plain array, and only writing to the array in the body of the constructor (after the field was properly initialized). It also removes the {Concat} method in favor or simply copying from two input arrays in a private constructor. Drive-by: Use proper constant names for the template parameters to make cpplint happy. R=ahaas@chromium.org Bug: v8:11384 Change-Id: Id748c8fef3c846069f91843f74d0555ed8ca9fb7 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2773799Reviewed-by: Andreas Haas <ahaas@chromium.org> Commit-Queue: Clemens Backes <clemensb@chromium.org> Cr-Commit-Position: refs/heads/master@{#73540}
Showing
Please
register
or
sign in
to comment