Unity-Technologies / qstat

New official qstat repository
Artistic License 2.0
121 stars 33 forks source link

iterator limit doesn't match malloc in protocol list code #21

Closed illwieckz closed 9 years ago

illwieckz commented 9 years ago

as @stevenh said in comments of #13,

In this code:

    sorted_types = (server_type **)malloc(sizeof(server_type*) * n_server_types);
    type = &types[0];
    for (i = 0; type->id != Q_UNKNOWN_TYPE; type++, i++) // ← HERE
    {
        sorted_types[i] = type;
    }

The iterator limit doesn't match malloc.

This issue is there since the initial revision.

illwieckz commented 9 years ago

This code must be refactored to be usable by some other parts (for example the json protocol listing).

illwieckz commented 9 years ago

I will probably not have time to code the 8 next days but I can merge existing code and re-push, so if you have a ready-to-use replacement I can copy-past it here and in qstat.c and add the commit to the PR.

illwieckz commented 9 years ago

@stevenh is this issue can be fixed? It's a 13 years old qstat issue and it blocks 5 pull requests to be merged.

The bug is still there in the last revision: https://github.com/multiplay/qstat/blob/2a95a5d04c8bed54b1a035607989dab101698ce4/qstat.c#L2655