S
S
Sergey Grigorov2018-09-23 16:45:15
JavaScript
Sergey Grigorov, 2018-09-23 16:45:15

What causes a stack overflow?

Hello. There is some function:

function db_prepare(table, columns){
    var weight = 0;
    var is = Core.dbcfg_tables.indexOf(table);
    if(is){
        weight = 1;
    }
    if(columns != undefined){
        var i;
        for(i in columns){
            i = columns[i].column;
            try{
                if(Core.dbcfg_structures[table].columns.indexOf(i) != undefined){
                    if(weight > 0){
                        weight = 2;
                    }else{
                        weight = 1;
                    }
                }else{
                    if(weight > 0){
                        weight = 1;
                    }else{
                        weight = 0;
                    }
                }
            }catch(Ex){
                if(weight > 0){
                    weight = 1;
                }else{
                    weight = 0;
                }
            }
        }
    }
    if(columns != undefined){
        if(weight < 2){
            return false;
        }else{
            return true;
        }
    }else{
        if(weight < 1){
            return false;
        }else{
            return true;
        }
    }
}

The debugger stubbornly tells me that there is a stack overflow in it (most likely, an eternal loop is created), but I can’t figure it out - what exactly is the problem here. The head after a productive night refuses to think.
Thank you in advance.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
vreitech, 2018-09-23
@Serjio-Grig

i = columns[i].column;
I don't like this line, I don't know why. and looked at her like that, and like that - you don’t like it, even if you crack.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question