diff --git a/cpp/ql/src/semmle/code/cpp/ir/implementation/aliased_ssa/Instruction.qll b/cpp/ql/src/semmle/code/cpp/ir/implementation/aliased_ssa/Instruction.qll index 432608372cf..f63f349e415 100644 --- a/cpp/ql/src/semmle/code/cpp/ir/implementation/aliased_ssa/Instruction.qll +++ b/cpp/ql/src/semmle/code/cpp/ir/implementation/aliased_ssa/Instruction.qll @@ -1341,17 +1341,23 @@ class SizedBufferMayWriteSideEffectInstruction extends WriteSideEffectInstructio } /** - * + * An instruction representing the initial value of newly allocated memory, e.g. the result of a + * call to `malloc` */ class InitializeDynamicAllocationInstruction extends SideEffectInstruction { InitializeDynamicAllocationInstruction() { getOpcode() instanceof Opcode::InitializeDynamicAllocation } - + + /** + * Gets the address of the allocation this instruction is initializing. + */ final AddressOperand getAllocationAddressOperand() { result = getAnOperand() } + /** + * Gets the operand for the allocation this instruction is initializing. + */ final Instruction getAllocationAddress() { result = getAllocationAddressOperand().getDef() } - } /** diff --git a/cpp/ql/src/semmle/code/cpp/ir/implementation/raw/Instruction.qll b/cpp/ql/src/semmle/code/cpp/ir/implementation/raw/Instruction.qll index 432608372cf..f63f349e415 100644 --- a/cpp/ql/src/semmle/code/cpp/ir/implementation/raw/Instruction.qll +++ b/cpp/ql/src/semmle/code/cpp/ir/implementation/raw/Instruction.qll @@ -1341,17 +1341,23 @@ class SizedBufferMayWriteSideEffectInstruction extends WriteSideEffectInstructio } /** - * + * An instruction representing the initial value of newly allocated memory, e.g. the result of a + * call to `malloc` */ class InitializeDynamicAllocationInstruction extends SideEffectInstruction { InitializeDynamicAllocationInstruction() { getOpcode() instanceof Opcode::InitializeDynamicAllocation } - + + /** + * Gets the address of the allocation this instruction is initializing. + */ final AddressOperand getAllocationAddressOperand() { result = getAnOperand() } + /** + * Gets the operand for the allocation this instruction is initializing. + */ final Instruction getAllocationAddress() { result = getAllocationAddressOperand().getDef() } - } /** diff --git a/cpp/ql/src/semmle/code/cpp/ir/implementation/unaliased_ssa/Instruction.qll b/cpp/ql/src/semmle/code/cpp/ir/implementation/unaliased_ssa/Instruction.qll index 432608372cf..f63f349e415 100644 --- a/cpp/ql/src/semmle/code/cpp/ir/implementation/unaliased_ssa/Instruction.qll +++ b/cpp/ql/src/semmle/code/cpp/ir/implementation/unaliased_ssa/Instruction.qll @@ -1341,17 +1341,23 @@ class SizedBufferMayWriteSideEffectInstruction extends WriteSideEffectInstructio } /** - * + * An instruction representing the initial value of newly allocated memory, e.g. the result of a + * call to `malloc` */ class InitializeDynamicAllocationInstruction extends SideEffectInstruction { InitializeDynamicAllocationInstruction() { getOpcode() instanceof Opcode::InitializeDynamicAllocation } - + + /** + * Gets the address of the allocation this instruction is initializing. + */ final AddressOperand getAllocationAddressOperand() { result = getAnOperand() } + /** + * Gets the operand for the allocation this instruction is initializing. + */ final Instruction getAllocationAddress() { result = getAllocationAddressOperand().getDef() } - } /** diff --git a/csharp/ql/src/semmle/code/csharp/ir/implementation/raw/Instruction.qll b/csharp/ql/src/semmle/code/csharp/ir/implementation/raw/Instruction.qll index 432608372cf..f63f349e415 100644 --- a/csharp/ql/src/semmle/code/csharp/ir/implementation/raw/Instruction.qll +++ b/csharp/ql/src/semmle/code/csharp/ir/implementation/raw/Instruction.qll @@ -1341,17 +1341,23 @@ class SizedBufferMayWriteSideEffectInstruction extends WriteSideEffectInstructio } /** - * + * An instruction representing the initial value of newly allocated memory, e.g. the result of a + * call to `malloc` */ class InitializeDynamicAllocationInstruction extends SideEffectInstruction { InitializeDynamicAllocationInstruction() { getOpcode() instanceof Opcode::InitializeDynamicAllocation } - + + /** + * Gets the address of the allocation this instruction is initializing. + */ final AddressOperand getAllocationAddressOperand() { result = getAnOperand() } + /** + * Gets the operand for the allocation this instruction is initializing. + */ final Instruction getAllocationAddress() { result = getAllocationAddressOperand().getDef() } - } /** diff --git a/csharp/ql/src/semmle/code/csharp/ir/implementation/unaliased_ssa/Instruction.qll b/csharp/ql/src/semmle/code/csharp/ir/implementation/unaliased_ssa/Instruction.qll index 432608372cf..f63f349e415 100644 --- a/csharp/ql/src/semmle/code/csharp/ir/implementation/unaliased_ssa/Instruction.qll +++ b/csharp/ql/src/semmle/code/csharp/ir/implementation/unaliased_ssa/Instruction.qll @@ -1341,17 +1341,23 @@ class SizedBufferMayWriteSideEffectInstruction extends WriteSideEffectInstructio } /** - * + * An instruction representing the initial value of newly allocated memory, e.g. the result of a + * call to `malloc` */ class InitializeDynamicAllocationInstruction extends SideEffectInstruction { InitializeDynamicAllocationInstruction() { getOpcode() instanceof Opcode::InitializeDynamicAllocation } - + + /** + * Gets the address of the allocation this instruction is initializing. + */ final AddressOperand getAllocationAddressOperand() { result = getAnOperand() } + /** + * Gets the operand for the allocation this instruction is initializing. + */ final Instruction getAllocationAddress() { result = getAllocationAddressOperand().getDef() } - } /**