Feature #4063

Add gammalib::getenv method

Added by Knödlseder Jürgen over 2 years ago. Updated over 2 years ago.

Status:ClosedStart date:06/04/2022
Priority:NormalDue date:
Assigned To:Knödlseder Jürgen% Done:

100%

Category:-
Target version:2.0.0
Duration:

Description

The std::getenv method may returns a pointer to NULL, hence assigning to std::string can lead to a memory leak in case that the environment variable does not exist. To make the code safe against memory leaks, a gammalib::getenv method should be added that catches the NULL pointers. The method should return an empty string in case that the environment variable does not exist.


Recurrence

No recurrence.

History

#1 Updated by Knödlseder Jürgen over 2 years ago

  • Status changed from New to Closed
  • % Done changed from 0 to 100

I implemented the function and make use of it in the unit tests. The code was merged into devel

Also available in: Atom PDF