Result should be checked against being NULL and an error code returned.