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

memory leak in g2_getfld() if errors occur reading message #160

Closed
edwardhartnett opened this issue Oct 27, 2021 · 0 comments · Fixed by #194
Closed

memory leak in g2_getfld() if errors occur reading message #160

edwardhartnett opened this issue Oct 27, 2021 · 0 comments · Fixed by #194
Assignees
Labels
bug Something isn't working

Comments

@edwardhartnett
Copy link
Contributor

In g2_getfld() we have:

lgfld = malloc(sizeof(gribfield));
Later in the code:

    if (istart == -1) {
        printf("g2_getfld:  Beginning characters GRIB not found.\n");
        ierr = 1;
        return(ierr);
    }

and

    if (istart == -1) {
        printf("g2_getfld:  Beginning characters GRIB not found.\n");
        ierr = 1;
        return(ierr);
    }

and

    /*  Currently handles only GRIB Edition 2. */
    if (ver != 2) {
        printf("g2_getfld: can only decode GRIB edition 2.\n");
        ierr = 2;
        return(ierr);
    }

and there are some other returns for error conditions. Note that they are not freeing the memory allocated in lgfld. There are (commented out) tests for this in tst_g2_addfield.c.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
1 participant