+2017-11-22 Jakub Jelinek <jakub@redhat.com>
+
+ PR libgomp/83106
+ * target.c (gomp_target_init): Compute lengths just once and
+ use them in both malloc size and subsequent copying.
+
2017-11-17 Igor Tsimbalist <igor.v.tsimbalist@intel.com>
* configure.ac: Set CET_FLAGS, update XCFLAGS and FCFLAGS.
do
{
struct gomp_device_descr current_device;
+ size_t prefix_len, suffix_len, cur_len;
next = strchr (cur, ',');
- plugin_name = (char *) malloc (1 + (next ? next - cur : strlen (cur))
- + strlen (prefix) + strlen (suffix));
+ prefix_len = strlen (prefix);
+ cur_len = next ? next - cur : strlen (cur);
+ suffix_len = strlen (suffix);
+
+ plugin_name = (char *) malloc (prefix_len + cur_len + suffix_len + 1);
if (!plugin_name)
{
num_devices = 0;
break;
}
- strcpy (plugin_name, prefix);
- strncat (plugin_name, cur, next ? next - cur : strlen (cur));
- strcat (plugin_name, suffix);
+ memcpy (plugin_name, prefix, prefix_len);
+ memcpy (plugin_name + prefix_len, cur, cur_len);
+ memcpy (plugin_name + prefix_len + cur_len, suffix, suffix_len + 1);
if (gomp_load_plugin_for_device (¤t_device, plugin_name))
{