Skip to content

P4Record crash #2

@milang

Description

@milang

(from David Hind)

I know it's an old project but I thought you might be interested in a bug I found in P4.Net.

It was crashing in P4Record.cs in this function:

private void processArray(string baseName)
{
    if (!_ArrayFields.ContainsKey(baseName))
    {
        List<string> list = new List<string>();
        for (int i = 0; ; i++)
        {
            string key = string.Format("{0}{1}", baseName, i);

            // fileSize will get us here too.  If a file is deleted and re-added,
            // the a filelog command will skip some numbers on the fileSize                    
            if (!_allFields.ContainsKey(key))
            {
                // peek ahead one file to see if one happend to be skipped
                string key2 = string.Format("{0}{1}", baseName, i + 1);
                if (_allFields.ContainsKey(key2))
                {
                    list.Add("");
                }
                else
                { 
                    break;
                }
            }
            list.Add(_allFields[key]);
        }

        _ArrayFields.Add(baseName, list.ToArray());
    }            
}

_allFields was missing a Key (it was filesize that didn't exist since the file was being deleted). It tries to add it anyway in list.add(_allFields[key]).

This is the fixed funciton:

private void processArray(string baseName)
{
    if (!_ArrayFields.ContainsKey(baseName))
    {
        List<string> list = new List<string>();
        for (int i = 0; ; i++)
        {
            string key = string.Format("{0}{1}", baseName, i);

            // fileSize will get us here too.  If a file is deleted and re-added,
            // the a filelog command will skip some numbers on the fileSize                    
            if (!_allFields.ContainsKey(key))
            {
                // peek ahead one file to see if one happend to be skipped
                string key2 = string.Format("{0}{1}", baseName, i + 1);
                if (_allFields.ContainsKey(key2))
                {
                    list.Add("");
                }
                else
                { 
                    break;
                }
            }
            else
            }
               list.Add(_allFields[key]);
            }
        }

        _ArrayFields.Add(baseName, list.ToArray());
    }            
}

I only saw this bug recently, which makes me suspicious (that something else changed). I know we did a perforce upgrade recently, so it might be related.

Cheers,

David.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions