[PATCH] winebuild: Fix a segmentation fault
When 'winebuild' is called with no arguments, the make_c_identifier function is passed a null pointer, which is dereferenced and causes a segmentation fault. This patch fixes that issue. Signed-off-by: James Larrowe <larrowe.semaj11(a)gmail.com> --- tools/winebuild/utils.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/tools/winebuild/utils.c b/tools/winebuild/utils.c index 95da1758c5..a6b1c102fd 100644 --- a/tools/winebuild/utils.c +++ b/tools/winebuild/utils.c @@ -816,10 +816,17 @@ char *make_c_identifier( const char *str ) { char *p, buffer[256]; - for (p = buffer; *str && p < buffer+sizeof(buffer)-1; p++, str++) + if ( str == NULL ) { - if (isalnum(*str)) *p = *str; - else *p = '_'; + return NULL; + } + else + { + for (p = buffer; *str && p < buffer+sizeof(buffer)-1; p++, str++) + { + if (isalnum(*str)) *p = *str; + else *p = '_'; + } } *p = 0; return xstrdup( buffer ); -- 2.20.1
participants (1)
-
James Larrowe