mirror of
https://github.com/ThrowTheSwitch/CMock.git
synced 2026-10-03 15:37:26 +00:00
Prevent undefined behavior due to typedef array usage.
This commit is contained in:
@@ -73,7 +73,10 @@ class CMockGeneratorUtils
|
||||
if (arg[:ptr?] or @treat_as.include?(arg[:type]))
|
||||
" #{dest} = #{arg[:name]};\n"
|
||||
else
|
||||
" memcpy(&#{dest}, &#{arg[:name]}, sizeof(#{arg[:type]}));\n"
|
||||
assert_expr = "sizeof(#{arg[:name]}) == sizeof(#{arg[:type]}) ? 1 : -1"
|
||||
comment = "/* add #{arg[:type]} to :treat_as_array if this causes an error */"
|
||||
" memcpy(&#{dest}, &#{arg[:name]},\n" +
|
||||
" sizeof(#{arg[:type]}[#{assert_expr}])); #{comment}\n"
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user