Closed Bug 212090 Opened 22 years ago Closed 22 years ago

nsInMemoryDataSource:GetSource() doesn't iterate over assertions correctly

Categories

(Core Graveyard :: RDF, defect)

x86
All
defect
Not set
normal

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: janv, Assigned: janv)

References

Details

Attachments

(1 file)

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.
Attached patch proposed fixSplinter Review
Attachment #127263 - Flags: superreview?(jaggernaut)
Attachment #127263 - Flags: review?(jaggernaut)
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)
Attachment #127263 - Flags: approval1.5a?
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?
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
checked in
Status: ASSIGNED → RESOLVED
Closed: 22 years ago
Resolution: --- → FIXED
Attachment #127263 - Flags: approval1.5a?
Product: Core → Core Graveyard
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: