From 79ab3b72a73f7d6896b1bd22ecf028c17dd5d187 Mon Sep 17 00:00:00 2001 From: Michael Uleysky Date: Sun, 7 Feb 2016 14:42:35 +1000 Subject: [PATCH] Gmt module: Fix potential segmentation fault. --- modules/gmt/modgmt_internals.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/modules/gmt/modgmt_internals.h b/modules/gmt/modgmt_internals.h index e8611cc..4b33dd9 100644 --- a/modules/gmt/modgmt_internals.h +++ b/modules/gmt/modgmt_internals.h @@ -33,7 +33,8 @@ inline struct GMT_OPTION* str2options(void *api, const char* str, size_t size=0) else { t=static_cast(malloc(size+1)); - memcpy(t,str,size+1); + memcpy(t,str,size); + t[size]=0; } struct GMT_OPTION* opts=GMT_Create_Options(api,0,t); GMT_Append_Option(api,GMT_Create_Options(api,0,default_gmt_options),opts);