Police officers searching for a missing toddler opened a cupboard in a 58-year-old woman's house and found a cannabis farm.
Inverness Sheriff Court heard that Mary Wells' illegal crop was discovered after police made door-to-door searches last July when the young child went missing near the River Ness in Inverness.
Her solicitor, Neil Wilson, told the court that his client could have refused officers access to her home, but didn't because she knew the welfare of a child was at stake.
"She knew full well that her cannabis plants would be found as a result. She was an occasional user and didn't want to pay anyone for the drug," he said, adding that Mrs Wells has now given up the drug.
The woman has been ordered to carry out 100 hours of unpaid community work.
The BBC reports that the missing child was eventually tracked down at a friend's house.