Skip to content
REFERENCE

leak

Default severity: warning · Identifier: weavec::leak

An owned resource is lost without being released, moved or stored where the caller can see it (RFC 0007): '<p>' is leaked at the point its last holder goes out of reach (a return, a scope end, the statement after its last use); '<p>' is leaked: it is overwritten without being released at the assignment; '<b>->p' is leaked when '<b>' is freed (also '*a' is leaked when 'a' is freed) at the release of a container whose WEAVEC_OWNED field, or a field this function stored an owned value into, still owns something; result of '<f>' is leaked at a discarded allocating call. Notes: allocated here, '<p>' is declared WEAVEC_OWNED here for a parameter or field, or reference taken here for a share retained by a count increment and dropped (RFC 0010; reported only through a known count: a field some function in the program releases through, or one annotated WEAVEC_REFCOUNT). Not reported: pointers handed to callees the checker cannot follow or cast to integers (they are escaped), resources kept by globals or static locals when the function returns, blocks that end in a noreturn call, fields of an object this function allocated, and the old block after a failed in-place realloc.

Release or transfer the owned resource on every applicable exit path. Before overwriting an owning pointer, dispose of the old resource. Free owned child allocations before their container. A shared cleanup label can make C error paths easier to audit.

Diagnostic controls · Checked guarantees