Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
f36d65c7
Commit
f36d65c7
authored
Jun 21, 2012
by
Martin v. Löwis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use GetEnvironmentVariableW instead of _wgetenv to silence VC warnings.
parent
56bf6f82
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
10 deletions
+19
-10
PC/launcher.c
PC/launcher.c
+19
-10
No files found.
PC/launcher.c
View file @
f36d65c7
...
@@ -54,22 +54,31 @@ skip_whitespace(wchar_t * p)
...
@@ -54,22 +54,31 @@ skip_whitespace(wchar_t * p)
}
}
/*
/*
* This function is here to minimise Visual Studio
* This function is here to simplify memory management
* warnings about security implications of getenv, and to
* and to treat blank values as if they are absent.
* treat blank values as if they are absent.
*/
*/
static
wchar_t
*
get_env
(
wchar_t
*
key
)
static
wchar_t
*
get_env
(
wchar_t
*
key
)
{
{
wchar_t
*
result
=
_wgetenv
(
key
);
/* This is not thread-safe, just like getenv */
static
wchar_t
buf
[
256
];
if
(
result
)
{
DWORD
result
=
GetEnvironmentVariableW
(
key
,
buf
,
256
);
result
=
skip_whitespace
(
result
);
if
(
*
result
==
L'\0'
)
if
(
result
>
256
)
{
result
=
NULL
;
/* Large environment variable. Accept some leakage */
wchar_t
*
buf2
=
(
wchar_t
*
)
malloc
(
sizeof
(
wchar_t
)
*
(
result
+
1
));
GetEnvironmentVariableW
(
key
,
buf2
,
result
);
return
buf2
;
}
}
return
result
;
if
(
result
==
0
)
/* Either some error, e.g. ERROR_ENVVAR_NOT_FOUND,
or an empty environment variable. */
return
NULL
;
return
buf
;
}
}
static
void
static
void
debug
(
wchar_t
*
format
,
...)
debug
(
wchar_t
*
format
,
...)
{
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment