From: Mark Adams Date: Thu, 15 Oct 2015 20:16:52 +0000 (-0400) Subject: Replace sprintf() usage with snprintf() X-Git-Tag: upstream/0.1~358^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=4123a04ca98e63d23b62f3bb0361bc5ff0e573c7;p=platform%2Fupstream%2Fglslang.git Replace sprintf() usage with snprintf() This fixes compilation in build environments with stricter warnings enabled --- diff --git a/glslang/MachineIndependent/preprocessor/Pp.cpp b/glslang/MachineIndependent/preprocessor/Pp.cpp index 406767a..72dbcae 100644 --- a/glslang/MachineIndependent/preprocessor/Pp.cpp +++ b/glslang/MachineIndependent/preprocessor/Pp.cpp @@ -1004,7 +1004,7 @@ int TPpContext::MacroExpand(int atom, TPpToken* ppToken, bool expandUndef, bool switch (atom) { case PpAtomLineMacro: ppToken->ival = parseContext.getCurrentLoc().line; - sprintf(ppToken->name, "%d", ppToken->ival); + snprintf(ppToken->name, sizeof(ppToken->name), "%d", ppToken->ival); UngetToken(PpAtomConstInt, ppToken); return 1; @@ -1012,14 +1012,14 @@ int TPpContext::MacroExpand(int atom, TPpToken* ppToken, bool expandUndef, bool if (parseContext.getCurrentLoc().name) parseContext.ppRequireExtensions(ppToken->loc, 1, &E_GL_GOOGLE_cpp_style_line_directive, "filename-based __FILE__"); ppToken->ival = parseContext.getCurrentLoc().string; - sprintf(ppToken->name, "%s", ppToken->loc.getStringNameOrNum().c_str()); + snprintf(ppToken->name, sizeof(ppToken->name), "%s", ppToken->loc.getStringNameOrNum().c_str()); UngetToken(PpAtomConstInt, ppToken); return 1; } case PpAtomVersionMacro: ppToken->ival = parseContext.version; - sprintf(ppToken->name, "%d", ppToken->ival); + snprintf(ppToken->name, sizeof(ppToken->name), "%d", ppToken->ival); UngetToken(PpAtomConstInt, ppToken); return 1;