Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
nexedi
cython
Commits
fbfadbbb
Commit
fbfadbbb
authored
Jul 13, 2015
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
guard strdup() call in embedding main function against memory errors
parent
d783750b
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
4 deletions
+4
-4
Cython/Utility/Embed.c
Cython/Utility/Embed.c
+4
-4
No files found.
Cython/Utility/Embed.c
View file @
fbfadbbb
...
@@ -164,19 +164,19 @@ int
...
@@ -164,19 +164,19 @@ int
}
}
else
{
else
{
int
i
,
res
;
int
i
,
res
;
char
*
oldloc
;
wchar_t
**
argv_copy
=
(
wchar_t
**
)
malloc
(
sizeof
(
wchar_t
*
)
*
argc
);
wchar_t
**
argv_copy
=
(
wchar_t
**
)
malloc
(
sizeof
(
wchar_t
*
)
*
argc
);
/* We need a second copy, as Python might modify the first one. */
/* We need a second copy, as Python might modify the first one. */
wchar_t
**
argv_copy2
=
(
wchar_t
**
)
malloc
(
sizeof
(
wchar_t
*
)
*
argc
);
wchar_t
**
argv_copy2
=
(
wchar_t
**
)
malloc
(
sizeof
(
wchar_t
*
)
*
argc
);
if
(
!
argv_copy
||
!
argv_copy2
)
{
char
*
oldloc
=
strdup
(
setlocale
(
LC_ALL
,
NULL
));
if
(
!
argv_copy
||
!
argv_copy2
||
!
oldloc
)
{
fprintf
(
stderr
,
"out of memory
\\
n"
);
fprintf
(
stderr
,
"out of memory
\\
n"
);
free
(
argv_copy
);
free
(
argv_copy
);
free
(
argv_copy2
);
free
(
argv_copy2
);
free
(
oldloc
);
return
1
;
return
1
;
}
}
oldloc
=
strdup
(
setlocale
(
LC_ALL
,
NULL
));
setlocale
(
LC_ALL
,
""
);
res
=
0
;
res
=
0
;
setlocale
(
LC_ALL
,
""
);
for
(
i
=
0
;
i
<
argc
;
i
++
)
{
for
(
i
=
0
;
i
<
argc
;
i
++
)
{
argv_copy2
[
i
]
=
argv_copy
[
i
]
=
__Pyx_char2wchar
(
argv
[
i
]);
argv_copy2
[
i
]
=
argv_copy
[
i
]
=
__Pyx_char2wchar
(
argv
[
i
]);
if
(
!
argv_copy
[
i
])
res
=
1
;
/* failure, but continue to simplify cleanup */
if
(
!
argv_copy
[
i
])
res
=
1
;
/* failure, but continue to simplify cleanup */
...
...
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