Both are correct. In some cases, the infinitive and gerund have the same meaning. It's important to note that this is not always true.
I love swimming.
I love to swim.
These have the same meaning. Sometimes the meaning is VERY different, like in these examples:
He forgot buying the wine for the party.
He forgot to buy the wine for the party.
I'm sure you can find a list of verbs that will explain this better. I'm looking, but I haven't found one I like yet.