summaryrefslogtreecommitdiffstats
path: root/src/H5G.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/H5G.c')
-rw-r--r--src/H5G.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/H5G.c b/src/H5G.c
index f6f0633..d08ac5b 100644
--- a/src/H5G.c
+++ b/src/H5G.c
@@ -2415,7 +2415,8 @@ H5G_get_comment(H5G_entry_t *loc, const char *name, size_t bufsize, char *buf)
buf[0] = '\0';
ret_value = 0;
} else {
- HDstrncpy(buf, comment.s, bufsize);
+ if(buf && bufsize)
+ HDstrncpy(buf, comment.s, bufsize);
ret_value = (int)HDstrlen(comment.s);
H5O_reset(H5O_NAME, &comment);
}