You might have noticed that the stock market doesn't seem phased much by the flurry of bad news lately. Surging COVID-19 cases. Persistent high unemployment. None of it seems to matter to Wall Street.

What's happening? Investors, as they always do, are looking ahead. They're expecting COVID-19 cases will decline and jobs will return. However, there's going to be a big problem if the sunny future being envisioned doesn't pan out.

It's only a matter of time until stocks plunge again. Whether that happens within the next few months or not, you'll want to be prepared. A smart strategy is to invest in stocks of companies built to survive and thrive over the long run. Here are three absolutely rock-solid stocks to buy before the next stock market crash.

Hand holding hourglass on top of cash

Image source: Getty Images.

Brookfield Infrastructure: Steady cash flow, sizzling dividend

Two words come to mind when I think about Brookfield Infrastructure (BIP 2.24%) (BIPC 1.54%): steady and sizzling. The company's cash flow is as steady as they come. And its dividend yield of 4.9% is downright sizzling.

There's a good reason for both pluses. Brookfield Infrastructure owns infrastructure assets that rake in big bucks month in and month out. These assets include cell towers, data centers, natural gas pipelines, ports, toll roads, and more. Around 95% of the company's cash flow is either regulated or contracted. That means Brookfield can count on money coming in the door pretty much no matter what happens with the economy.

Some might think an infrastructure company is boring. But when times get rough, boring can be beautiful. However, Brookfield Infrastructure has delivered annualized annual returns in the high teens since the company was founded. That's not boring at all to me.

Sure, Brookfield Infrastructure's shares could fall in another market crash. The important thing to know, though, is that its business will remain strong. Brookfield Infrastructure is solid with a strong moat that isn't going to falter. That's the kind of company you want to own when the market goes haywire.

Dollar General: A winner in good and bad times

Are there stocks that can perform well when the market falls and when it rises? Yep. Dollar General (DG 4.39%) serves as a great example.

The discount retailer becomes even more attractive to consumers during economic downturns. Shoppers like Dollar General's low prices when they're tightening their purse strings. It also helps significantly that the company's stores are conveniently located for many Americans.

If the next stock market crash is related to the COVID-19 pandemic, Dollar General could be in an even stronger position than it normally would. Its stores carry the necessities that consumers need. The stores are also smaller than those of major rivals like Walmart. That's advantageous when customers seek to avoid large crowds to avoid being infected by the coronavirus.

Dollar General is also in a great position to prosper during good economic times. That's exactly what happened in the five years prior to 2020, with the company's shares soaring 120%. Dollar General is poised to succeed in a post-pandemic world, just as it did in the pre-pandemic world.

Vertex Pharmaceuticals: The best biotech money can buy

You might not think of biotech stocks as rock-solid. It's true that many biotechs are very risky. However, Vertex Pharmaceuticals (VRTX 1.36%) is arguably the best biotech that money can buy right now. 

Vertex enjoys a monopoly in the market for drugs that treat the underlying cause of cystic fibrosis (CF). No other company is even close to launching a product that would compete against Vertex's CF drugs. The success of these drugs has generated huge profits for Vertex ($1.2 billion last year). They've also enabled the biotech to amass a sizable cash stockpile of more than $4 billion.

It's a pretty safe bet that Vertex's sales and earnings will keep growing regardless of what happens with the economy or the stock market. Patients aren't going to quit taking their CF medications. And with European approval of Kaftrio (which is marketed under the brand name Trikafta in the U.S.) appearing to be a slam dunk, Vertex could soon see a big sales jump. 

The biotech also plans to expand its market beyond CF. Vertex and partner CRISPR Therapeutics are evaluating a promising candidate targeting rare genetic diseases beta-thalassemia and sickle cell disease in phase 1/2 clinical studies. Vertex's pipeline includes other candidates targeting rare genetic diseases and a program targeting pain relief in phase 2 testing. If some of these experimental drugs are successful, this rock-solid biotech could remain the best that money can buy for a long time to come.