Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-winehq
Commits
b48d8124
Commit
b48d8124
authored
Sep 24, 2003
by
Alexandre Julliard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Rewrote getenv and _wgetenv to avoid returning a pointer to a freed
memory block.
parent
7add08a3
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
28 additions
and
43 deletions
+28
-43
environ.c
dlls/msvcrt/environ.c
+28
-43
No files found.
dlls/msvcrt/environ.c
View file @
b48d8124
...
...
@@ -35,27 +35,20 @@ WINE_DEFAULT_DEBUG_CHANNEL(msvcrt);
*/
char
*
MSVCRT_getenv
(
const
char
*
name
)
{
char
*
environ
=
GetEnvironmentStringsA
();
char
*
pp
,
*
pos
=
NULL
;
unsigned
int
length
=
strlen
(
name
);
for
(
pp
=
environ
;
(
*
pp
);
pp
=
pp
+
strlen
(
pp
)
+
1
)
{
pos
=
strchr
(
pp
,
'='
);
if
((
pos
)
&&
((
pos
-
pp
)
==
length
))
{
if
(
!
strncasecmp
(
pp
,
name
,
length
))
break
;
}
}
if
((
*
pp
)
&&
(
pos
))
{
pp
=
pos
+
1
;
TRACE
(
"got %s
\n
"
,
pp
);
}
else
pp
=
0
;
FreeEnvironmentStringsA
(
environ
);
return
pp
;
char
**
environ
;
unsigned
int
length
=
strlen
(
name
);
for
(
environ
=
*
__p__environ
();
*
environ
;
environ
++
)
{
char
*
str
=
*
environ
;
char
*
pos
=
strchr
(
str
,
'='
);
if
(
pos
&&
((
pos
-
str
)
==
length
)
&&
!
strncasecmp
(
str
,
name
,
length
))
{
TRACE
(
"(%s): got %s
\n
"
,
debugstr_a
(
name
),
debugstr_a
(
pos
+
1
));
return
pos
+
1
;
}
}
return
NULL
;
}
/*********************************************************************
...
...
@@ -63,28 +56,20 @@ char *MSVCRT_getenv(const char *name)
*/
MSVCRT_wchar_t
*
_wgetenv
(
const
MSVCRT_wchar_t
*
name
)
{
MSVCRT_wchar_t
*
environ
=
GetEnvironmentStringsW
();
MSVCRT_wchar_t
*
pp
,
*
pos
=
NULL
;
unsigned
int
length
=
strlenW
(
name
);
for
(
pp
=
environ
;
(
*
pp
);
pp
=
pp
+
strlenW
(
pp
)
+
1
)
{
pos
=
strchrW
(
pp
,
'='
);
if
((
pos
)
&&
((
pos
-
pp
)
==
length
))
{
if
(
!
strncmpiW
(
pp
,
name
,
length
))
{
pp
=
pos
+
1
;
TRACE
(
"got %s
\n
"
,
debugstr_w
(
pp
));
/* can't free pointer since we are returning it */
/* should probably use MSVCRT_wenviron instead */
FIXME
(
"memory leak
\n
"
);
return
pp
;
}
}
}
FreeEnvironmentStringsW
(
environ
);
return
NULL
;
MSVCRT_wchar_t
**
environ
;
unsigned
int
length
=
strlenW
(
name
);
for
(
environ
=
*
__p__wenviron
();
*
environ
;
environ
++
)
{
MSVCRT_wchar_t
*
str
=
*
environ
;
MSVCRT_wchar_t
*
pos
=
strchrW
(
str
,
'='
);
if
(
pos
&&
((
pos
-
str
)
==
length
)
&&
!
strncmpiW
(
str
,
name
,
length
))
{
TRACE
(
"(%s): got %s
\n
"
,
debugstr_w
(
name
),
debugstr_w
(
pos
+
1
));
return
pos
+
1
;
}
}
return
NULL
;
}
/*********************************************************************
...
...
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