Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect indexing in NCDISPATCH_initialize() #1518

Closed
ckhroulev opened this issue Nov 11, 2019 · 3 comments · Fixed by #1527
Closed

Incorrect indexing in NCDISPATCH_initialize() #1518

ckhroulev opened this issue Nov 11, 2019 · 3 comments · Fixed by #1527
Assignees
Milestone

Comments

@ckhroulev
Copy link
Contributor

Looking at the code of NetCDF-C 4.7.2 (commit 108e938) I noticed that NCDISPATCH_initialize() contains the following:

    {
	size_t* c0 = (size_t*)NC_coord_zero;
	size_t* c1 = (size_t*)NC_coord_one;
	ptrdiff_t* s1 = (ptrdiff_t*)NC_stride_one;
        for(i=0;i<NC_MAX_VAR_DIMS;i++) {
	    c0[0] = 0;
	    c1[i] = 1;
	    s1[i] = 1;
	}
    }

I suspect that c0[0] above should be replaced by c0[i]. This code was introduced by #1379.

Please feel free to close this if the code quoted above is correct as it stands.

@WardF WardF self-assigned this Nov 12, 2019
@WardF WardF added this to the 4.7.3 milestone Nov 12, 2019
@WardF
Copy link
Member

WardF commented Nov 12, 2019

I believe you are correct, and I am tagging in @DennisHeimbigner just to confirm.

@DennisHeimbigner
Copy link
Collaborator

You are correct, although it may have overtaken by a later change,

@ckhroulev
Copy link
Contributor Author

You are correct, although it may have overtaken by a later change,

Not in the master branch - I checked before I opened this issue.

Note, though, that c0, c1, and s1 should also be removed now that there's no need cast away const (see #1486 and #1495).

ckhroulev added a commit to ckhroulev/netcdf-c that referenced this issue Nov 14, 2019
@ckhroulev ckhroulev changed the title Potentially incorrect indexing in NCDISPATCH_initialize() Incorrect indexing in NCDISPATCH_initialize() Nov 14, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants