From the Baltimore Catechism:
Q. 1156. Are bad dreams sinful in themselves?
A. Bad dreams are not sinful in themselves, because we cannot prevent them, but we may make them sinful: 1.(1) By taking pleasure in them when we awake, and 2.(2) By bad reading or immodest looks, thoughts, word or actions before going to sleep; for by any of these things we may make ourselves responsible for the bad dreams.