Closed Bug 1699206 Opened 3 years ago Closed 3 years ago

Handle NULL exception for folder index when retrieving folder modes

Categories

(Thunderbird :: Folder and Message Lists, task)

Tracking

(thunderbird_esr78 unaffected)

RESOLVED FIXED
88 Branch
Tracking Status
thunderbird_esr78 --- unaffected

People

(Reporter: aleca, Assigned: aleca)

References

Details

Attachments

(1 file)

As per alta88 comment:

@@ -592,17 +590,19 @@ var gFolderTreeView = {
* view. Defaults to false.
* @returns true if the folder selection was successful, false if it failed
* (probably because the folder isn't in the view at all)
*/
selectFolder(aFolder, aForceSelect = false) {
// "this" inside the nested function refers to the function...
// Also note that openIfNot is recursive.
let tree = this;

  • let folderTreeMode = this._modes[this._mode];
  • let mode = this.getModeForIndex(this.getIndexOfFolder(aFolder));
  • let folderTreeMode = this._modes[mode];
    If you read the comment for getIndexOfFolder() you will see it can return null, and getModeForIndex() does not handle that. Tabs as folders manifest this. Please follow up, thanks.
Attachment #9209820 - Flags: review?(mkmelin+mozilla)
Comment on attachment 9209820 [details] [diff] [review]
1699206-folder-index-null.diff

Review of attachment 9209820 [details] [diff] [review]:
-----------------------------------------------------------------

Seems ok to me. r=mkmelin
Attachment #9209820 - Flags: review?(mkmelin+mozilla) → review+
Target Milestone: --- → 88 Branch

There are other callers, null is not the only possibility, so that is a wrong and insufficient way to test for the validity of a index to be used for 0 based array access.

Isn't this method only returning an INT or NULL?
https://searchfox.org/comm-central/rev/2ebf654a54e51c83febc5a891482f3419ebe3fa2/mail/base/content/folderPane.js#662-669

The getModeForIndex() method only expects an index pointer, or a NULL in case the the getIndexOfFolder() method is used.
Can you point out other scenarios in the code?

Pushed by geoff@darktrojan.net:
https://hg.mozilla.org/comm-central/rev/74e427ca4c3b
Handle NULL exception for folder index when retrieving folder modes. r=mkmelin

Status: ASSIGNED → RESOLVED
Closed: 3 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: