Skip to content

Commit 10a0c01

Browse files
committed
Pointers returned by getenv must not be manipulated
In partiular, pointers need not and must not be free'd -- but still shouldn't be considered memory leaks.
1 parent 4f88473 commit 10a0c01

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/ansi-c/library/stdlib.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -301,6 +301,8 @@ inline long atol(const char *nptr)
301301
#define __CPROVER_LIMITS_H_INCLUDED
302302
#endif
303303

304+
inline void *__builtin_alloca(__CPROVER_size_t alloca_size);
305+
304306
inline char *getenv(const char *name)
305307
{
306308
__CPROVER_HIDE:;
@@ -330,7 +332,7 @@ inline char *getenv(const char *name)
330332
// the range.
331333

332334
__CPROVER_assume(1<=buf_size && buf_size<=SSIZE_MAX);
333-
buffer=(char *)__CPROVER_malloc(buf_size);
335+
buffer=(char *)__builtin_alloca(buf_size);
334336
buffer[buf_size-1]=0;
335337

336338
return buffer;

0 commit comments

Comments
 (0)