@@ -1139,6 +1139,9 @@ struct
11391139
11401140 (* interpreter end *)
11411141
1142+ let is_not_alloc_var ctx v =
1143+ not (ctx.ask (Queries. IsAllocVar v))
1144+
11421145 let is_not_heap_alloc_var ctx v =
11431146 let is_alloc = ctx.ask (Queries. IsAllocVar v) in
11441147 not is_alloc || (is_alloc && not (ctx.ask (Queries. IsHeapVar v)))
@@ -1277,7 +1280,7 @@ struct
12771280 (* If there's a non-heap var or an offset in the lval set, we answer with bottom *)
12781281 (* If we're asking for the BlobSize from the base address, then don't check for offsets => we want to avoid getting bot *)
12791282 if AD. exists (function
1280- | Addr (v ,o ) -> is_not_heap_alloc_var ctx v || (if not from_base_addr then o <> `NoOffset else false )
1283+ | Addr (v ,o ) -> is_not_alloc_var ctx v || (if not from_base_addr then o <> `NoOffset else false )
12811284 | _ -> false ) a then
12821285 Queries.Result. bot q
12831286 else (
@@ -1289,9 +1292,15 @@ struct
12891292 else
12901293 a
12911294 in
1292- let r = get ~full: true (Analyses. ask_of_ctx ctx) ctx.global ctx.local a None in
1295+ let r = get ~full: true (Analyses. ask_of_ctx ctx) ctx.global ctx.local a None in
12931296 (* ignore @@ printf "BlobSize %a = %a\n" d_plainexp e VD.pretty r; *)
12941297 (match r with
1298+ | Array a ->
1299+ (* unroll into array for Calloc calls *)
1300+ (match ValueDomain.CArrays. get (Queries. to_value_domain_ask (Analyses. ask_of_ctx ctx)) a (None , (IdxDom. of_int (Cilfacade. ptrdiff_ikind () ) BI. zero)) with
1301+ | Blob (_ ,s ,_ ) -> `Lifted s
1302+ | _ -> Queries.Result. top q
1303+ )
12951304 | Blob (_ ,s ,_ ) -> `Lifted s
12961305 | _ -> Queries.Result. top q)
12971306 )
0 commit comments