Skip to content

Don’t try to add nil strings to an array. #408

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Sep 5, 2014
Merged

Conversation

robrix
Copy link
Contributor

@robrix robrix commented Sep 3, 2014

This can occur if one or more of the strings in strarray is invalid UTF8.

We’ve got a user seeing this when we’re pulling in their branch names. The on-disk .git/refs/* look ok, but I wonder if there’s something funky going on with the decomposed UTF16 filenames → assumed valid null-terminated UTF8 conversion in @(cStr).

To wit, I think we should probably not be assuming valid null-terminated UTF8 here, but I’m not sure what we should assume instead.

I haven’t been able to synthesize a failing case (of filename → nil string literal) yet.

This can occur if one or more of the strings in `strarray` is invalid
UTF8.
@joshaber joshaber self-assigned this Sep 4, 2014
@joshaber
Copy link
Member

joshaber commented Sep 4, 2014

👍

This is certainly better than crashing. I recall running into a thing where ASCII worked where UTF8 didn't (https://twitter.com/jspahrsummers/status/453653597989777408) but I can't for the life of me remember the context.

Maybe we should try to fall back to ASCII if UTF8 fails?

@robrix
Copy link
Contributor Author

robrix commented Sep 4, 2014

There’s at least one case where we’re doing UTF8, falling back to ISOLatin1, falling back to MacRoman. I’m not sure if that’s the better approach or if UTF8 falling back to ASCII is.

I’m surprised that there’s no error parameter for any of those constructors, or the corresponding CFString variants.

@joshaber
Copy link
Member

joshaber commented Sep 4, 2014

Yeah the lack of errors is a bummer.

Maybe use the lossy ASCII conversion? Seems like that's most likely to actually give us something.

@robrix
Copy link
Contributor Author

robrix commented Sep 4, 2014

Good call 👍

@robrix
Copy link
Contributor Author

robrix commented Sep 5, 2014

🔶

@joshaber
Copy link
Member

joshaber commented Sep 5, 2014

🎇

joshaber added a commit that referenced this pull request Sep 5, 2014
Don’t try to add `nil` strings to an array.
@joshaber joshaber merged commit f522cab into master Sep 5, 2014
@joshaber joshaber deleted the fix-strarray-bridging branch September 5, 2014 22:14
phatblat pushed a commit to phatblat/objective-git that referenced this pull request Sep 13, 2014
Don’t try to add `nil` strings to an array.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants