Closed Bug 1308094 Opened 6 years ago Closed 9 months ago

Replace PL_strdup/PL_strfree with strdup / free

Categories

(Core :: XPCOM, defect, P5)

defect

Tracking

()

RESOLVED FIXED
93 Branch
Tracking Status
firefox93 --- fixed

People

(Reporter: cpeterson, Assigned: smurfd)

References

(Blocks 2 open bugs)

Details

(Whiteboard: [lang=c++][ele:1a])

Attachments

(3 files)

We want to replace NSPR functions with standard C functions if they available on all platforms. This bug is probably not a good-first-bug because there are some special cases to consider.

1. Replace PL_strdup() calls with strdup() outside of nsprpub/ and security/nss code:

https://searchfox.org/mozilla-central/search?q=PL_strdup&path=.cpp%24&case=false&regexp=false

*** CAUTION: PL_strdup(nullptr) will return "", but strdup(nullptr) will crash! Any calls to PL_strdup() that are changed to strdup() should be carefully audited to see if they might need to handle a null pointer, with code like strdup(str ? str : "") or maybe returning an error.

2. Replace PL_strfree() calls with free():

https://searchfox.org/mozilla-central/search?q=PL_strfree&path=.cpp%24&case=false&regexp=false

3. Add #include <string.h> if it's needed for strdup()'s function declaration.

4. Remove #include "plstr.h" if it's no longer needed for other NSPR string function declarations.
Mentor: cpeterson
Waldo recommends using a safer Gecko string class or function instead of just swapping PL_strdup() for strdup().
Summary: Replace PL_strdup/PL_strfree with strdup/free → Replace PL_strdup/PL_strfree with a safer Gecko string class or function
Component: General → String
Component: String → XPCOM
Blocks: 1724649
Assignee: nobody → smurfd
Status: NEW → ASSIGNED
Attachment #9235459 - Attachment description: Bug 1308094 - Replace PL_strdup/PL_strfree with a safer Gecko string class or function r=#necko-reviewers → Bug 1308094 - Remove deprecrated PL_strdup calls from toolkit code r=gijs
Attachment #9235459 - Attachment description: Bug 1308094 - Remove deprecrated PL_strdup calls from toolkit code r=gijs → Bug 1308094 - Remove deprecrated PL_strdup calls from toolkit code r=gijs
Attachment #9235460 - Attachment description: Bug 1308094 - Replace PL_strdup/PL_strfree with a safer Gecko string class or function r=#xpcom-reviewers → Bug 1308094 - Remove PL_strdup and PL_strfree from BloatEntry r=#xpcom-reviewers,mccr8
Attachment #9235459 - Attachment description: Bug 1308094 - Remove deprecrated PL_strdup calls from toolkit code r=gijs → Bug 1308094 - Remove deprecated PL_strdup calls from toolkit code r=gijs
Attachment #9235461 - Attachment description: Bug 1308094 - Replace PL_strdup/PL_strfree with a safer Gecko string class or function r=valentin → Bug 1308094 - Remove deprecated PL_strdup and PL_strfree calls from modules code r=valentin
Summary: Replace PL_strdup/PL_strfree with a safer Gecko string class or function → Replace PL_strdup/PL_strfree with strdup / free
Pushed by amccreight@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/48be7a726d32
Remove deprecated PL_strdup calls from toolkit code r=Gijs
https://hg.mozilla.org/integration/autoland/rev/da16c4f3a988
Remove PL_strdup and PL_strfree from BloatEntry r=xpcom-reviewers,mccr8
https://hg.mozilla.org/integration/autoland/rev/ada63ac5146d
Remove deprecated PL_strdup and PL_strfree calls from modules code r=valentin
Status: ASSIGNED → RESOLVED
Closed: 9 months ago
Resolution: --- → FIXED
Target Milestone: --- → 93 Branch
You need to log in before you can comment on or make changes to this bug.