File tree Expand file tree Collapse file tree 1 file changed +23
-15
lines changed
Expand file tree Collapse file tree 1 file changed +23
-15
lines changed Original file line number Diff line number Diff line change @@ -522,21 +522,29 @@ and size_of_btype_array (t: btype_t) (len: bexp_t): int traceresult =
522522
523523
524524and size_of_btype_comp (comp : bcompinfo_t ): int traceresult =
525- if comp.bcstruct then
526- let lastoff =
527- List. fold_left (fun acc_r finfo ->
528- tbind (fun acc -> offset_of_field_acc ~finfo ~acc ) acc_r)
529- (Ok start_oa) comp.bcfields in
530- let size =
531- tmap2 (fun o a -> add_trailing o.oa_first_free a)
532- lastoff (align_of_btype (TComp (comp.bckey, [] ))) in
533- size
534- else (* union *)
535- let fieldsizes =
536- List. map (fun finfo -> size_of_btype finfo.bftype) comp.bcfields in
537- let size =
538- tfold_list_fail (fun mx a -> if a > mx then a else mx) (Ok 0 ) fieldsizes in
539- size
525+ let size =
526+ if comp.bcstruct then
527+ let lastoff =
528+ List. fold_left (fun acc_r finfo ->
529+ tbind (fun acc -> offset_of_field_acc ~finfo ~acc ) acc_r)
530+ (Ok start_oa) comp.bcfields in
531+ let size =
532+ tmap2 (fun o a -> add_trailing o.oa_first_free a)
533+ lastoff (align_of_btype (TComp (comp.bckey, [] ))) in
534+ size
535+ else (* union *)
536+ let fieldsizes =
537+ List. map (fun finfo -> size_of_btype finfo.bftype) comp.bcfields in
538+ let size =
539+ tfold_list_fail (fun mx a -> if a > mx then a else mx) (Ok 0 ) fieldsizes in
540+ size in
541+ tbind
542+ (fun size ->
543+ if size = 0 then
544+ Error [__FILE__ ^ " :" ^ (string_of_int __LINE__) ^ " : "
545+ ^ " zero size for compinfo: " ^ comp.bcname]
546+ else
547+ Ok size) size
540548
541549
542550and offset_of_field_acc
You can’t perform that action at this time.
0 commit comments