From d94af8cc89075107bf40a40c7ecde19b03064ffe Mon Sep 17 00:00:00 2001 From: Ward Fisher Date: Sat, 19 Apr 2014 14:18:53 -0600 Subject: [PATCH 1/4] Fixed clang-reported error: calling strlen on null pointer. --- ncgen/main.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/ncgen/main.c b/ncgen/main.c index e6b326e87..534025f36 100644 --- a/ncgen/main.c +++ b/ncgen/main.c @@ -412,7 +412,10 @@ main( cdlname = (char*)emalloc(NC_MAX_NAME); cdlname = nulldup(argv[0]); - if(strlen(cdlname) > NC_MAX_NAME) cdlname[NC_MAX_NAME] = '\0'; + if(cdlname != NULL) { + if(strlen(cdlname) > NC_MAX_NAME) + cdlname[NC_MAX_NAME] = '\0'; + } } /* Standard Unidata java interface => usingclassic */ From 01598ae6101913e175509a2bf86b8b6231e7cafd Mon Sep 17 00:00:00 2001 From: Ward Fisher Date: Sat, 19 Apr 2014 17:55:01 -0600 Subject: [PATCH 2/4] Fixed clang-reported issue: memory leak. --- libdispatch/ncaux.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libdispatch/ncaux.c b/libdispatch/ncaux.c index 4ce5e5bdf..046f22cb4 100644 --- a/libdispatch/ncaux.c +++ b/libdispatch/ncaux.c @@ -130,6 +130,8 @@ ncaux_add_field(void* tag, const char *name, nc_type field_type, cmpd->nfields++; done: + if(newfields) + free(newfields); return status; } From ff47046e93e41ed81295ae86f54e8d00ccbf54b4 Mon Sep 17 00:00:00 2001 From: Ward Fisher Date: Sat, 19 Apr 2014 17:57:25 -0600 Subject: [PATCH 3/4] Fixed clang-reported issue: memory leak. --- libsrc4/nc4hdf.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/libsrc4/nc4hdf.c b/libsrc4/nc4hdf.c index e03d9b3de..1d41f21b6 100644 --- a/libsrc4/nc4hdf.c +++ b/libsrc4/nc4hdf.c @@ -2320,7 +2320,7 @@ write_dim(NC_DIM_INFO_T *dim, NC_GRP_INFO_T *grp, int write_dimid) if (v1) { - hsize_t *new_size; + hsize_t *new_size = NULL; NC_GRP_INFO_T *g; NC_DIM_INFO_T *dim1; int d1; @@ -2347,8 +2347,10 @@ write_dim(NC_DIM_INFO_T *dim, NC_GRP_INFO_T *grp, int write_dimid) } } } - if (H5Dset_extent(v1->hdf_datasetid, new_size) < 0) - BAIL(NC_EHDFERR); + if (H5Dset_extent(v1->hdf_datasetid, new_size) < 0) { + free(new_size); + BAIL(NC_EHDFERR); + } free(new_size); } } @@ -2363,6 +2365,7 @@ write_dim(NC_DIM_INFO_T *dim, NC_GRP_INFO_T *grp, int write_dimid) return NC_NOERR; exit: + return retval; } From 4ae47ad45b146755aaa427e9ec8bbc0807c9ac3d Mon Sep 17 00:00:00 2001 From: Dennis Heimbigner Date: Mon, 21 Apr 2014 10:13:27 -0600 Subject: [PATCH 4/4] jna? --- cf | 1 - libsrc4/nc4file.c | 54 +++++++++++++++++++++++++++++++++++------------ wjna | 4 ++-- 3 files changed, 43 insertions(+), 16 deletions(-) diff --git a/cf b/cf index fae23b642..ac3bca2b2 100644 --- a/cf +++ b/cf @@ -24,7 +24,6 @@ CFLAGS="" PREFIX=/usr/local stddir="/usr/local" - if test "x$cmds" = x ; then cmds="" #cmds="all" diff --git a/libsrc4/nc4file.c b/libsrc4/nc4file.c index 37f3c2c28..ec3bb0c6c 100644 --- a/libsrc4/nc4file.c +++ b/libsrc4/nc4file.c @@ -1161,6 +1161,10 @@ read_type(NC_GRP_INFO_T *grp, hid_t hdf_typeid, char *type_name) { int nmembers; unsigned int m; + char* member_name = NULL; +#ifdef JNA + char jna[1001]; +#endif type->nc_type_class = NC_COMPOUND; @@ -1171,22 +1175,32 @@ read_type(NC_GRP_INFO_T *grp, hid_t hdf_typeid, char *type_name) { hid_t member_hdf_typeid; hid_t member_native_typeid; - char *member_name; size_t member_offset; H5T_class_t mem_class; nc_type member_xtype; + retval = NC_NOERR; + /* Get the typeid and native typeid of this member of the * compound type. */ if ((member_hdf_typeid = H5Tget_member_type(type->native_hdf_typeid, m)) < 0) return NC_EHDFERR; + if ((member_native_typeid = H5Tget_native_type(member_hdf_typeid, H5T_DIR_DEFAULT)) < 0) return NC_EHDFERR; /* Get the name of the member.*/ member_name = H5Tget_member_name(type->native_hdf_typeid, m); - if (!member_name || strlen(member_name) > NC_MAX_NAME) - return NC_EBADNAME; + if (!member_name || strlen(member_name) > NC_MAX_NAME) { + retval = NC_EBADNAME; + break; + } +#ifdef JNA + else { + strncpy(jna,member_name,1000); + member_name = jna; + } +#endif /* Offset in bytes on *this* platform. */ member_offset = H5Tget_member_offset(type->native_hdf_typeid, m); @@ -1200,42 +1214,55 @@ read_type(NC_GRP_INFO_T *grp, hid_t hdf_typeid, char *type_name) hsize_t dims[NC_MAX_VAR_DIMS]; int d; - if ((ndims = H5Tget_array_ndims(member_hdf_typeid)) < 0) - return NC_EHDFERR; - if (H5Tget_array_dims(member_hdf_typeid, dims, NULL) != ndims) - return NC_EHDFERR; + if ((ndims = H5Tget_array_ndims(member_hdf_typeid)) < 0) { + retval = NC_EHDFERR; + break; + } + if (H5Tget_array_dims(member_hdf_typeid, dims, NULL) != ndims) { + retval = NC_EHDFERR; + break; + } for (d = 0; d < ndims; d++) dim_size[d] = dims[d]; /* What is the netCDF typeid of this member? */ if ((retval = get_netcdf_type(grp->nc4_info, H5Tget_super(member_hdf_typeid), &member_xtype))) - return retval; + break; /* Add this member to our list of fields in this compound type. */ if ((retval = nc4_field_list_add(&type->u.c.field, type->u.c.num_fields++, member_name, member_offset, H5Tget_super(member_hdf_typeid), H5Tget_super(member_native_typeid), member_xtype, ndims, dim_size))) - return retval; + break; } else { /* What is the netCDF typeid of this member? */ if ((retval = get_netcdf_type(grp->nc4_info, member_native_typeid, &member_xtype))) - return retval; + break; /* Add this member to our list of fields in this compound type. */ if ((retval = nc4_field_list_add(&type->u.c.field, type->u.c.num_fields++, member_name, member_offset, member_hdf_typeid, member_native_typeid, member_xtype, 0, NULL))) - return retval; + break; } - /* HDF5 allocated this for us. */ - free(member_name); +#ifndef JNA + /* Free the member name (which HDF5 allocated for us). */ + if(member_name != NULL) free(member_name); +#endif + member_name = NULL; } +#ifndef JNA + if(member_name != NULL) + free(member_name); +#endif + if(retval) /* error exit from loop */ + return retval; } break; @@ -1363,6 +1390,7 @@ read_type(NC_GRP_INFO_T *grp, hid_t hdf_typeid, char *type_name) #endif member_name = NULL; } + #ifndef JNA if(member_name != NULL) free(member_name); diff --git a/wjna b/wjna index d673537c4..82e3aa3de 100644 --- a/wjna +++ b/wjna @@ -2,8 +2,8 @@ REBUILD=1 -VS=12 -#VS=10 +#VS=12 +VS=10 JNADIR="c:/opt/jna"