Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
L
libSDL
Project
Project
Details
Activity
Releases
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
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
PocketInsanity
libSDL
Commits
42bac7a3
Commit
42bac7a3
authored
Feb 08, 2011
by
Sam Lantinga
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed stack overflow on Windows
parent
91275892
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
4 deletions
+14
-4
SDL_log.c
src/SDL_log.c
+14
-4
No files found.
src/SDL_log.c
View file @
42bac7a3
...
@@ -233,7 +233,7 @@ GetCategoryPrefix(int category)
...
@@ -233,7 +233,7 @@ GetCategoryPrefix(int category)
void
void
SDL_LogMessageV
(
int
category
,
SDL_LogPriority
priority
,
const
char
*
fmt
,
va_list
ap
)
SDL_LogMessageV
(
int
category
,
SDL_LogPriority
priority
,
const
char
*
fmt
,
va_list
ap
)
{
{
char
message
[
SDL_MAX_LOG_MESSAGE
]
;
char
*
message
;
/* Make sure we don't exceed array bounds */
/* Make sure we don't exceed array bounds */
if
(
priority
<
0
||
priority
>=
SDL_NUM_LOG_PRIORITIES
)
{
if
(
priority
<
0
||
priority
>=
SDL_NUM_LOG_PRIORITIES
)
{
...
@@ -245,17 +245,26 @@ SDL_LogMessageV(int category, SDL_LogPriority priority, const char *fmt, va_list
...
@@ -245,17 +245,26 @@ SDL_LogMessageV(int category, SDL_LogPriority priority, const char *fmt, va_list
return
;
return
;
}
}
SDL_vsnprintf
(
message
,
SDL_arraysize
(
message
),
fmt
,
ap
);
message
=
SDL_stack_alloc
(
char
,
SDL_MAX_LOG_MESSAGE
);
if
(
!
message
)
{
return
;
}
SDL_vsnprintf
(
message
,
SDL_MAX_LOG_MESSAGE
,
fmt
,
ap
);
#if defined(__WIN32__)
#if defined(__WIN32__)
/* Way too many allocations here, urgh */
{
{
char
output
[
32
+
SDL_MAX_LOG_MESSAGE
];
char
*
output
;
size_t
length
;
LPTSTR
tstr
;
LPTSTR
tstr
;
SDL_snprintf
(
output
,
SDL_arraysize
(
output
),
"%s: %s"
,
SDL_priority_prefixes
[
priority
],
message
);
length
=
SDL_strlen
(
SDL_priority_prefixes
[
priority
])
+
2
+
SDL_strlen
(
message
)
+
1
;
output
=
SDL_stack_alloc
(
char
,
length
);
SDL_snprintf
(
output
,
length
,
"%s: %s"
,
SDL_priority_prefixes
[
priority
],
message
);
tstr
=
WIN_UTF8ToString
(
output
);
tstr
=
WIN_UTF8ToString
(
output
);
OutputDebugString
(
tstr
);
OutputDebugString
(
tstr
);
SDL_free
(
tstr
);
SDL_free
(
tstr
);
SDL_stack_free
(
output
);
}
}
#elif defined(__ANDROID__)
#elif defined(__ANDROID__)
{
{
...
@@ -268,6 +277,7 @@ SDL_LogMessageV(int category, SDL_LogPriority priority, const char *fmt, va_list
...
@@ -268,6 +277,7 @@ SDL_LogMessageV(int category, SDL_LogPriority priority, const char *fmt, va_list
#if HAVE_STDIO_H
#if HAVE_STDIO_H
fprintf
(
stderr
,
"%s: %s
\n
"
,
SDL_priority_prefixes
[
priority
],
message
);
fprintf
(
stderr
,
"%s: %s
\n
"
,
SDL_priority_prefixes
[
priority
],
message
);
#endif
#endif
SDL_stack_free
(
message
);
}
}
/* vi: set ts=4 sw=4 expandtab: */
/* vi: set ts=4 sw=4 expandtab: */
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