suppose there is a function which allocates memory for a temporary variable temp , does some work and then returns temp.

i think there should be a memory leak in this case as i cannot free temp ,right so how can i control memory leak here