There was a PDF exploit in Safari in iOS 4 on the iPhone, which is how comex and other members of the iPhone Dev Team were able to jailbreak it. But Apple quickly found out about it, and released a patch for it. However, this patch (iOS 4.0.2 or iOS 4.1) will cause you to lose your jailbreak and your unlock, possibly forever! So don’t do it.
Instead, do this: