aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/pj_param.c2
-rw-r--r--src/projects.h7
2 files changed, 7 insertions, 2 deletions
diff --git a/src/pj_param.c b/src/pj_param.c
index 6cee4d1f..7ed0e377 100644
--- a/src/pj_param.c
+++ b/src/pj_param.c
@@ -42,7 +42,7 @@ paralist *pj_mkparam_ws (char *str) {
}
/* Use calloc to automagically 0-terminate the copy */
- newitem = (paralist *) pj_calloc (1, sizeof(paralist) + len);
+ newitem = (paralist *) pj_calloc (1, sizeof(paralist) + len + 1);
if (0==newitem)
return 0;
memmove(newitem->param, str, len);
diff --git a/src/projects.h b/src/projects.h
index 2dc073fa..928985f6 100644
--- a/src/projects.h
+++ b/src/projects.h
@@ -458,7 +458,12 @@ struct PJconsts {
struct ARG_list {
paralist *next;
char used;
- char param[1];
+#ifdef __GNUC__
+ char param[0]; /* variable-length member */
+ /* Safer to use [0] for gcc. See https://github.com/OSGeo/proj.4/pull/1087 */
+#else
+ char param[1]; /* variable-length member */
+#endif
};