The barrel and slide numbers are irrelevant. The frame serial is all that matters. A quick Google search reveals mismatched numbers on Glocks are common. It's not as if they're hand-fitted like old S&W revolvers, or are ever going to be collectibles, and numbers matching parts actually means something.
This is quite correct from a legal stand point. I was speaking more from the standpoint of someone who, even when buying used, looks for honest use, but all original.
Mismatched numbers are always an indication that something has happened after the fact making the pistol not the way it left the factory.
Mismatched numbers could be the result of intentionally or unintentionally swapped parts (think group disassembly/cleaning on an armory table or in an ultrasonic bath), factory replacement parts, which raises the flag of why the part was replaced (i.e. blown barrel, cracked slide, or damaged frame, and what kind of abuse may have happened to require such replacement), and as one poster pointed out, it could simply be an after-market barrel, but such is easily recognized, and if I were looking at a used Glock with an after-market barrel, I would ask for the original to be included in the sale.
Now, all of those concerns having been addressed, if such matters do not bother a buyer (they do bother me as LE trade-in or other used Glocks are not priced THAT much lower than new ones to justify the concerns/excuses if it is not all original), and if the pistol is otherwise safe (I am not sure how you know that for sure other than shooting which often cannot be done unless there is a range in the store), then by all means, buy it and remember that, as -db- points out, the official serial number is the one on the frame.