Hi steelcat and dznuts, as stated by dznuts, a firewall is a program which helps analyse and protect outgoing and incoming connections and prevent unauthorised access.
It is impossible for a firewall to prevent a malware infection because it is internet based.
Some of the malware are transmitted via secondary storage devices such as flash drives, CD's/DVD's, memory cards, etc., in such cases, a firewall is useless as it does not monitor USB ports and CD/DVD drives.
You will have to install an antivirus and an antispyware software each.
In a nutshell, a firewall does not prevent a malware infection. It just prevents unauthorised access and notifies the user when an intrusion attempt is made.