Closed
Bug 212090
Opened 22 years ago
Closed 22 years ago
nsInMemoryDataSource:GetSource() doesn't iterate over assertions correctly
Categories
(Core Graveyard :: RDF, defect)
Tracking
(Not tracked)
RESOLVED
FIXED
People
(Reporter: janv, Assigned: janv)
References
Details
Attachments
(1 file)
821 bytes,
patch
|
bugs
:
review+
jag+mozilla
:
superreview+
|
Details | Diff | Splinter Review |
I found this bug while I was working on bug 199501.
GetSource() and GetSources() implementation should be very similar, except that
GetSource() returns only the first source.
I compared both methods in nsInMemoryDataSource and I found a problem in
GetSource().
This is how GetSources() iterates over assertions
http://lxr.mozilla.org/mozilla/source/rdf/base/src/nsInMemoryDataSource.cpp#568
mSource is null in this case since we are actually looking for a source.
So it can be simplified to
mNextAssertion = mNextAssertion->u.as.mInvNext;
But when you look at GetSource() implementation
http://lxr.mozilla.org/mozilla/source/rdf/base/src/nsInMemoryDataSource.cpp#1092
you found that it uses |as = as->mNext| which is in my opinion incorrect.
To be sure I put some printfs around and I found that GetSource() is not used
very often. GetSources() is used a lot. So we can assume that GetSources()
implementation is more likely correct.
I'll attach a patch.
Assignee | ||
Comment 1•22 years ago
|
||
Assignee | ||
Updated•22 years ago
|
Attachment #127263 -
Flags: superreview?(jaggernaut)
Attachment #127263 -
Flags: review?(jaggernaut)
Comment 2•22 years ago
|
||
Comment on attachment 127263 [details] [diff] [review]
proposed fix
Looks like you're right.
Ben, could you r= this?
Attachment #127263 -
Flags: superreview?(jaggernaut)
Attachment #127263 -
Flags: superreview+
Attachment #127263 -
Flags: review?(jaggernaut)
Attachment #127263 -
Flags: review?(ben)
![]() |
||
Comment 3•22 years ago
|
||
Attachment #127263 -
Flags: review?(ben) → review+
Assignee | ||
Updated•22 years ago
|
Attachment #127263 -
Flags: approval1.5a?
![]() |
||
Comment 4•22 years ago
|
||
Seems reasonable to me. cc'ing rjc, who was probably the last person to fiddle
with this stuff.
So what's this fixing, and what's the risk? (What could it break, and how
likely is it to break?) Could some callers be depending on the old behavior?
Assignee | ||
Comment 6•22 years ago
|
||
Say you have this kind of data in an in-memory data source:
source | name property | host property | database property
---------------------------------------------------------------
urn:sqltest | sqltest | localhost | sometest
now when I call GetSource(GetResource(SQL_NS + "Name"), GetLiteral("sqltest"))
I'll get "urn:sqltest" which is correct.
if I change it like this:
source | name property | host property | database property
---------------------------------------------------------------
urn:sqltest | sqltest | localhost | sqltest
I won't get anything. GetSource just doesn't work in this case.
I already landed fix for bug 199501 which depends on this bug. Without this fix
alias managemenet in SQL support is broken.
Three people agreed that this good thing to do and I didn't see any problems
with this patch.
But some weird code can always depend on the old behaviour, but only if it meets
the same kind of data.
Blocks: 199501
Status: NEW → ASSIGNED
Assignee | ||
Comment 7•22 years ago
|
||
checked in
Status: ASSIGNED → RESOLVED
Closed: 22 years ago
Resolution: --- → FIXED
Updated•22 years ago
|
Attachment #127263 -
Flags: approval1.5a?
Updated•7 years ago
|
Product: Core → Core Graveyard
You need to log in
before you can comment on or make changes to this bug.
Description
•