Instead of calling resize, which would compare against the uninitialized dimensions values, initialize dimensions and needsResize directly.
Instead of calling resize, which would compare against the uninitialized dimensions values, initialize dimensions and needsResize directly.