[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[netCDF #PHC-148715]: Suggested change to netcdf-cxx-4.2 code
- Subject: [netCDF #PHC-148715]: Suggested change to netcdf-cxx-4.2 code
- Date: Fri, 26 Dec 2014 19:18:37 -0700
Hello,
Thank you for the patch. The C++ 4.2 libraries are deprecated (as you note),
but I will take a look to see if the same issue occurs in the latest C++
libraries and, if so, will apply your patch to address the issue.
Thanks again, have a great day,
-Ward
> Hi
>
> In debugging netcdf apps using valgrind, I get warnings related to the
> use of uninitialized variables.
>
> In the older C++ lib, I suggest that you change the NcVar constructor to
> be as follows:
>
> NcVar::NcVar(NcFile* nc, int id)
> : NcTypedComponent(nc), the_id(id)
> {
> char nam[NC_MAX_NAME];
> memset(nam, 0, NC_MAX_NAME); <<<===== add this line
> if (the_file
> && NcError::set_err(
> nc_inq_varname(the_file->id(), the_id, nam)
> ) == NC_NOERR) {
> the_name = new char[1 + strlen(nam)];
> strcpy(the_name, nam);
> } else {
> the_name = 0;
> }
> init_cur();
> }
>
> i.e. add the memset call to clear the nam variable before it is used.
>
> I did this in a valgrind test environment and it cleared up a lot of
> warnings.
>
> Thanks
>
> Mike Dixon
>
>
>
Ticket Details
===================
Ticket ID: PHC-148715
Department: Support netCDF
Priority: Normal
Status: Closed