Commit a5c6d5eb08141b9a833ae9bada1b2ded4c7539d3
1 parent
fe516999
Exists in
master
and in
109 other branches
\0 for char attribute
Showing
1 changed file
with
2 additions
and
1 deletions
Show diff stats
php/src/ncvar_attr.c
... | ... | @@ -52,9 +52,10 @@ main(int argc, char **argv) |
52 | 52 | if (xtype == NC_CHAR) { |
53 | 53 | size_t attlen = 0; |
54 | 54 | check(nc_inq_attlen(ncID, varID, name_in, &attlen)); |
55 | - unsigned char *string_attr = (unsigned char *)malloc(attlen * sizeof(char*)); | |
55 | + unsigned char *string_attr = (unsigned char *)malloc(attlen * sizeof(char*) + 1); | |
56 | 56 | |
57 | 57 | check(nc_get_att(ncID, varID, name_in, string_attr)); |
58 | + strcpy(&string_attr[attlen],"\0"); | |
58 | 59 | fprintf(stdout, "%s\n", string_attr); |
59 | 60 | free(string_attr); |
60 | 61 | } | ... | ... |