albertodemichelis / squirrel

Official repository for the programming language Squirrel
http://www.squirrel-lang.org
MIT License
895 stars 149 forks source link

fix squirrel warning: ‘nArgs’ may be used uninitialized in this function in squirrel/squirrel/sqbaselib.cpp #205

Closed henningw closed 4 years ago

henningw commented 4 years ago

Synchronize from kamailio project (uses squirrel internally) - fix a compiler warning. The (adapted) diff below. Please consider for integration into your repository.

commit 7fad9c51f71854e0649fe76e273190e4b4f82438
Author: Henning Westerholt <hw@skalatan.de>
Date:   Sat Nov 23 18:53:17 2019 +0100

    app_sqlang: fix squirrel warning: ‘nArgs’ may be used uninitialized in this function

diff --git a/squirrel/squirrel/sqbaselib.cpp b/squirrel/squirrel/sqbaselib.cpp
--- a/squirrel/squirrel/sqbaselib.cpp
+++ b/squirrel/squirrel/sqbaselib.cpp
@@ -625,7 +625,7 @@ static SQInteger __map_array(SQArray *dest,SQArray *src,HSQUIRRELVM v) {
     SQObject &closure = stack_get(v, 2);
     v->Push(closure);

-    SQInteger nArgs;
+    SQInteger nArgs = 0;
     if(sq_type(closure) == OT_CLOSURE) {
         nArgs = _closure(closure)->_function->_nparameters;
     }
linuxmaniac commented 4 years ago

@henningw I took the liberty of send the PR with the fix

henningw commented 4 years ago

@linuxmaniac thanks you!