Closed Bug 99245 Opened 23 years ago Closed 23 years ago

Using strtok is evil

Categories

(Core :: Preferences: Backend, defect)

x86
Linux
defect
Not set
normal

Tracking

()

VERIFIED FIXED

People

(Reporter: drepper, Assigned: bnesse)

Details

Attachments

(3 files)

Some code in modules/libpref/src still uses strtok.  strtok really must not be
used since it's not thread-safe and not even save to call inbetween sucessive
calls in the same thread.  I'll shortly attach a patch.  The patch also changes
configure.in.  I'll file a few more strtok bugs and some include the same
configure.in change.  So there might be a conflict.
Keywords: patch, review
to prefs backend.
Assignee: sgehani → bnesse
Component: Preferences → Preferences: Backend
Not that there appears to be anything wrong with the patch but... The fact that
it only addresses one of the five references to strtok in prefapi.c implies to
me that you are trying to fix a specific bug as opposed to general cleanup. Is
that true?

nsIPref, and therefore NextChild(), is depricated. Changing the calling code to
use nsIPrefService and nsIPrefBranch and using GetChildList() would be
preferable to me. This is not to say, however, that I will stand in the way
landing this patch if there is a good reason for it...
Hum, don't know why the other strtok changes in perfapi are not included. 
Probably I attached the wrong file.  I'll attach an updated, complete patch
(without the configure change which is already in the CVS archive).

And the nsPref.cpp change you cannot leave out until the last user of the code
is gone.
Comment on attachment 49354 [details] [diff] [review]
updated, complete patch

Seems ok to me. r=bnesse.
Attachment #49354 - Flags: review+
sr=alecf
Fix checked into the trunk.
Status: NEW → RESOLVED
Closed: 23 years ago
Resolution: --- → FIXED
Reopening, since the change to prefapi.c should say |&nextStr| instead of
|nextStr|, and there's also some funky indentation.
really
Status: RESOLVED → REOPENED
Resolution: FIXED → ---
Comment on attachment 51259 [details] [diff] [review]
proposed additional patch

oops! bad super-reviewer, no cookie... :)
sr=alecf
Attachment #51259 - Flags: superreview+
Comment on attachment 51259 [details] [diff] [review]
proposed additional patch

Hmm. oops. r=bnesse.
Attachment #51259 - Flags: review+
Revision to fix checked in 2001-09-28 22:55:53 PDT.  Marking FIXED again.
Status: REOPENED → RESOLVED
Closed: 23 years ago23 years ago
Resolution: --- → FIXED
rs vrfy
Status: RESOLVED → VERIFIED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: