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

Warnings for code in nc4hdf5.c/hdf5file.c #999

Closed
edhartnett opened this issue May 17, 2018 · 2 comments · Fixed by #1112
Closed

Warnings for code in nc4hdf5.c/hdf5file.c #999

edhartnett opened this issue May 17, 2018 · 2 comments · Fixed by #1112

Comments

@edhartnett
Copy link
Contributor

*** CID 1435639:  Control flow issues  (DEADCODE)
/home/tester/netcdf-c-cov-1526580857/libhdf5/hdf5file.c: 1888 in read_var()
1882         * same name as a dimension. It's legal in netcdf, and requires
1883         * that the HDF5 dataset name be changed. */
1884        if (strlen(obj_name) > strlen(NON_COORD_PREPEND) &&
1885            !strncmp(obj_name, NON_COORD_PREPEND, strlen(NON_COORD_PREPEND)))
1886        {
1887           /* Allocate space for the name. */
>>>     CID 1435639:  Control flow issues  (DEADCODE)
>>>     Execution cannot reach this statement: "free(finalname);".
1888           if(finalname) {free(finalname); finalname = NULL;}
1889           if (!(finalname = malloc(((strlen(obj_name) - strlen(NON_COORD_PREPEND))+ 1) * sizeof(char))))
1890              BAIL(NC_ENOMEM);
1891           strcpy(finalname, &obj_name[strlen(NON_COORD_PREPEND)]);
1892        } else
1893            finalname = strdup(obj_name);

** CID 1435638:  Null pointer dereferences  (FORWARD_NULL)
/home/tester/netcdf-c-cov-1526580857/libhdf5/hdf5file.c: 2888 in NC4_enddef()
*** CID 1435638:  Null pointer dereferences  (FORWARD_NULL)
/home/tester/netcdf-c-cov-1526580857/libhdf5/hdf5file.c: 2888 in NC4_enddef()
2882           return NC_EBADGRPID;
2883     
2884        /* when exiting define mode, mark all variable written */
2885        for (i=0; i<ncindexsize(grp->vars); i++) {
2886           NC_VAR_INFO_T* var = (NC_VAR_INFO_T*)ncindexith(grp->vars,i);
2887           if(var != NULL) continue;
>>>     CID 1435638:  Null pointer dereferences  (FORWARD_NULL)
>>>     Dereferencing null pointer "var".
2888           var->written_to = NC_TRUE;
2889        }
2890     
2891        return nc4_enddef_netcdf4_file(nc4_info);
2892     }
2893     

** CID 1435637:  Resource leaks  (RESOURCE_LEAK)
/home/tester/netcdf-c-cov-1526580857/libsrc/memio.c: 705 in readfile()```

I will take care of these once current PRs have been cleared.
@edhartnett
Copy link
Contributor Author

Also:

*** CID 1435632:  Null pointer dereferences  (REVERSE_INULL)
/home/tester/netcdf-c-cov-1526580857/libhdf5/hdf5file.c: 475 in att_read_var_callbk()
469     
470           /* Read the rest of the info about the att,
471            * including its values. */
472           if ((retval = read_hdf5_att(att_info->grp, attid, att)))
473             BAIL(retval);
474     
>>>     CID 1435632:  Null pointer dereferences  (REVERSE_INULL)
>>>     Null-checking "att" suggests that it may be null, but it has already been dereferenced on all paths leading to the check.
475           if (att)
476              att->created = NC_TRUE;
477     
478           if (attid > 0 && H5Aclose(attid) < 0)
479              BAIL2(NC_EHDFERR);
480     

** CID 1435631:  Null pointer dereferences  (FORWARD_NULL)

@edhartnett
Copy link
Contributor Author

I have fixed these in my lazy var branch and will put up a PR when the backlog clears a bit.

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