Stop using nsAutoPtr for holding primitive arrays in MailNews due to bug 1241901

RESOLVED FIXED in Thunderbird 47.0

Status

Thunderbird
General
RESOLVED FIXED
2 years ago
2 years ago

People

(Reporter: Jorg K (GMT+2), Assigned: Jorg K (GMT+2))

Tracking

Trunk
Thunderbird 47.0

Firefox Tracking Flags

(Not tracked)

Details

Attachments

(1 attachment, 2 obsolete attachments)

(Assignee)

Description

2 years ago
Looks like this
https://hg.mozilla.org/mozilla-central/rev/673a9080e14d
broke the compile at least here:

c:\mozilla-source\comm-central\obj-i686-pc-mingw32\dist\include\nsAutoPtr.h(26) : error C2338: If you are using nsAutoPtr to hold an array, use UniquePtr<T[]> instead
c:/mozilla-source/comm-central/mailnews/base/src/nsMessenger.cpp(154) : see reference to class template instantiation 'nsAutoPtr<char>' being compiled
(Assignee)

Comment 1

2 years ago
Created attachment 8714015 [details] [diff] [review]
Bustage fix (v1).

I derived the fix looking at
https://hg.mozilla.org/mozilla-central/rev/673a9080e14d#l7.49

I've also tried:
-#include "nsAutoPtr.h"
+#include "mozilla/UniquePtr.h"

-  nsAutoPtr<char> m_dataBuffer;
+  mozilla::UniquePtr<char[]> m_dataBuffer;

-  m_dataBuffer = new char[FOUR_K];
+  m_dataBuffer = mozilla::MakeUnique<char[]>(FOUR_K);

but that gave all sorts of hassle where m_dataBuffer is passed as a char*.

Luckily there is only one occurrence in the whole C-C tree of this.
Assignee: nobody → mozilla
Status: NEW → ASSIGNED
Attachment #8714015 - Flags: review?(Pidgeot18)
(Assignee)

Comment 2

2 years ago
Actually, this needs to change, too: if (m_dataBuffer && m_outputStream)
(Assignee)

Comment 3

2 years ago
Created attachment 8714018 [details] [diff] [review]
Bustage fix (v2).

More tweaks. Sorry.
Attachment #8714015 - Attachment is obsolete: true
Attachment #8714015 - Flags: review?(Pidgeot18)
Attachment #8714018 - Flags: review?(Pidgeot18)

Updated

2 years ago
Depends on: 1241901
Summary: Bustage of 30 Jan 2016 due to bug 1241901 → Stop using nsAutoPtr for holding primitive arrays in MailNews due to bug 1241901
(In reply to Jorg K (GMT+1) from comment #1)
> but that gave all sorts of hassle where m_dataBuffer is passed as a char*.

You probably should replace all of them with m_dataBuffer.get() rather than inline a 4k array in the class.
(Assignee)

Comment 5

2 years ago
Created attachment 8714024 [details] [diff] [review]
Alternate patch according to Xidorn's comment #4.
Attachment #8714024 - Flags: review?(Pidgeot18)
(Assignee)

Comment 6

2 years ago
Kent, perhaps you can get to this before Joshua. BTW, the second patch was inspired by
https://hg.mozilla.org/mozilla-central/rev/673a9080e14d#l4.32
Flags: needinfo?(rkent)
Comment on attachment 8714018 [details] [diff] [review]
Bustage fix (v2).

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

This one looks better.
Attachment #8714018 - Flags: review?(Pidgeot18) → review+
Attachment #8714024 - Flags: review?(Pidgeot18)

Comment 8

2 years ago
https://hg.mozilla.org/comm-central/rev/de29414d264853d08ced88a2b416107b18b31607
Bug 1244466 - Port Bug 1241901 part 4 - Stop using nsAutoPtr for holding primitive arrays. r=jcranmer a=aleth CLOSED TREE

Updated

2 years ago
Status: ASSIGNED → RESOLVED
Last Resolved: 2 years ago
Resolution: --- → FIXED
Target Milestone: --- → Thunderbird 47.0

Updated

2 years ago
Flags: needinfo?(rkent)

Updated

2 years ago
Attachment #8714024 - Attachment is obsolete: true
You need to log in before you can comment on or make changes to this bug.