All Downloads are FREE. Search and download functionalities are using the official Maven repository.

scripts.c.malloc-leak.sc Maven / Gradle / Ivy

The newest version!
//> using file assertions.sc

@main def main(inputPath: String) = {
  importCode(inputPath)
  def allocated            = cpg.call("malloc").inAssignment.target.dedup
  def freed                = cpg.call("free").argument(1)
  def flowsFromAllocToFree = freed.reachableBy(allocated).toSetImmutable
  val leaks                = allocated.map(_.code).toSetImmutable.diff(flowsFromAllocToFree.map(_.code))

  val expected = Set("leak")
  assertContains("leaks", leaks, expected)

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy