Skip to content
This repository was archived by the owner on Aug 8, 2023. It is now read-only.
This repository was archived by the owner on Aug 8, 2023. It is now read-only.

Use std::vector for MGLMultiPoint coordinate storage #6580

Closed

Description

@1ec5

MGLMultiPoint represents its coordinates internally as a C array of CLLocationCoordinate2D instances. This was fine at first, because the coordinates were immutable once MGLMultiPoint was created. Making the coordinates mutable (#6565) is forcing us to reckon with manual C memory management. Any errors there could potentially turn into security vulnerabilities.

We should convert the internal _coordinates array into an std::vector<CLLocationCoordinate2D> and let that object handle heap allocations for us. The public coordinates property would be implemented as _coordinates.data(), and pointCount as _coordinates.size(). The upshot is that the memcpy() grunt work in #6565 could be replaced with nothing more than std::vector::reserve() and std::copy_backward().

/cc @incanus @boundsj @alulsh

Activity

  1. added
    iOS
    macOS
    annotations
    on Oct 4, 2016
  2. added this to the ios-v3.4.0 milestone on Oct 5, 2016
  3. 1ec5 commented on Oct 5, 2016

    @1ec5
    ContributorAuthor

    Putting this on the v3.4.0 milestone. #6565 and #6583 only increase the risk of making an off-by-one error that can’t be detected by unit tests yet could lead to security vulnerabilities.

  4. incanus commented on Oct 7, 2016

    @incanus
    Contributor

    Re: being on the milestone, the original feature in #6565 was driven by a customer request and is "gravy" of a sort (mmmmm) beyond the focus on 3.4.0, which is runtime styling.

    Maybe consider this a loose milestone issue that can be punted on? We can always tighten things up in a point release.

    /cc @boundsj

  5. 1ec5 commented on Oct 7, 2016

    @1ec5
    ContributorAuthor

    Even if we punt on #6583, I think we should keep this refactoring on the milestone. It’s small and necessary given that we have no tests of this functionality. (Or we can add tests!) #6565 (comment) is illustrative of the murky waters we’re in right now.

  6. added
    release blocker
    on Oct 24, 2016
  7. boundsj commented on Oct 24, 2016

    @boundsj
    Contributor

    Adding release blocker tag due to the safety concerns raised here

  8. self-assigned this
    on Nov 2, 2016
  9. boundsj commented on Nov 14, 2016

    @boundsj
    Contributor

    This was fixed in #6890

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

annotationsiOSmacOSrefactorrelease blocker

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions