Null Reference Exception with List wrapped in a scriptable object

I’m using a scriptable object to hold a list of sprites for the player character, and setting the correct sprite to use from a settings menu by storing the index in PlayerPrefs. Somehow, I’m getting a null reference exception when I first access the list in the scriptable object, but then the game continues running correctly (and accesses the data that it said was null).

    public SpriteHolder spriteHolder;

    void Start () {

    void SetSprite()
        int spriteIndex = PlayerPerfManager.GetSprite();

        SpriteRenderer renderer = GetComponent<SpriteRenderer>();
        if (spriteHolder.sprites.Count > 0) // ** Error on this line**
            Debug.Log("Sprite list is not empty.");

        if (spriteIndex > spriteHolder.sprites.Count) // ** No error on this line**
            spriteIndex = 0;

        renderer.sprite = spriteHolder.sprites[spriteIndex];

and the scriptable object:

public class SpriteHolder : ScriptableObject {

    public string type;
    public List<Sprite> sprites;	

The Sprite Holder asset is created in the inspector and the spriteHolder variable is set in the inspector. I get the null reference exception on the line marked. However, the debug statement is getting printed before the game pauses for the error, and if I unpause the game it works just fine (loading the correct sprite, etc.). Additionally, there is no null reference exception at the next if statement, even though it accesses the same field.

This seems like black magic to me… Any idea what’s going on here?

Thank you in advance!

Edited to include Start().

Problem solved! Turns out I’m an idiot, and I had two copies of the script attached to my prefab. One copy had a null reference and the other didn’t.