@@ -1096,27 +1096,25 @@ static bool add_version_info_entry(void *p_context, MCArrayRef p_array, MCNameRe
10961096 if (p_context == nil)
10971097 return true ;
10981098
1099- MCWindowsVersionInfo *t_string;
11001099 MCExecContext ctxt (nil, nil, nil);
11011100 MCAutoStringRef t_value;
1102- /* UNCHECKED */ ctxt . ConvertToString (p_value, &t_value);
1103- byte_t *t_bytes;
1104- uindex_t t_byte_count;
1105- /* UNCHECKED */ MCStringConvertToBytes (*t_value, kMCStringEncodingUTF16LE , false , t_bytes, t_byte_count);
1101+ if (!ctxt . ConvertToString (p_value, &t_value))
1102+ return false ;
1103+
1104+ MCAutoArray<byte_t > t_bytes;
1105+ if (!MCStringConvertToBytes (*t_value, kMCStringEncodingUTF16LE , false , t_bytes . PtrRef (), t_bytes . SizeRef ()))
1106+ return false ;
11061107
11071108 // FG-2014-09-17: [[ Bugfix 13463 ]] Convert may return 0 bytes for the empty string
1108- if (t_byte_count == 0 || t_bytes[t_byte_count - 1 ] != ' \0 ' || t_bytes[t_byte_count - 2 ] != ' \0 ' )
1109+ if (t_bytes . Size () == 0 || t_bytes[t_bytes . Size () - 1 ] != ' \0 ' || t_bytes[t_bytes . Size () - 2 ] != ' \0 ' )
11091110 {
1110- byte_t * temp = t_bytes;
1111- t_bytes = new byte_t [t_byte_count + 2 ];
1112- memcpy (t_bytes, temp, t_byte_count);
1113- t_byte_count +=2 ;
1114- delete temp;
1115- t_bytes[t_byte_count - 2 ] = ' \0 ' ;
1116- t_bytes[t_byte_count - 1 ] = ' \0 ' ;
1111+ if (!t_bytes . Push (' \0 ' ) ||
1112+ !t_bytes . Push (' \0 ' ))
1113+ return false ;
11171114 }
11181115
1119- return MCWindowsVersionInfoAdd ((MCWindowsVersionInfo *)p_context, MCNameGetCString (p_key), true , t_bytes, t_byte_count, t_string);
1116+ MCWindowsVersionInfo *t_string;
1117+ return MCWindowsVersionInfoAdd ((MCWindowsVersionInfo *)p_context, MCNameGetCString (p_key), true , t_bytes . Ptr (), t_bytes . Size (), t_string);
11201118}
11211119
11221120static bool MCWindowsResourcesAddVersionInfo (MCWindowsResources& self, MCArrayRef p_info)
0 commit comments