Skip to content
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

add nil detect in toStringWithQuotesEscaped to prevent crash #158

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

recih
Copy link

@recih recih commented Jun 4, 2016

when field.name is nil, it will crash.

@kstenerud
Copy link
Owner

Are you sure this code is crashing? It should just return nil since a method was called on a nil object. I also tested all places it's called from, and they don't crash with nil arguments.

@recih
Copy link
Author

recih commented Jun 6, 2016

er.. I'm not so sure. But i got a crash report like this, maybe we can discuss:

Exception Type:  EXC_CRASH (SIGABRT)
Exception Codes: 0x0000000000000000, 0x0000000000000000
Crashed Thread:  0

Last Exception Backtrace:
0   CoreFoundation                  0x321343e2 __exceptionPreprocess + 158
1   libobjc.A.dylib                 0x39e2f95e objc_exception_throw + 26
2   CoreFoundation                  0x32137dbc +[NSObject(NSObject) doesNotRecognizeSelector:] + 180
3   CoreFoundation                  0x32136648 ___forwarding___ + 388
4   CoreFoundation                  0x3208e204 _CF_forwarding_prep_0 + 20
5   app                             0x00d89456 -[NSString(URLEncode) URLEncoded] + 30
6   app                             0x00d95d00 -[KSHTTPMultipartPostBody data] + 540
7   app                             0x00d8a898 -[KSCrashReportSinkQuincy filterReports:bodyName:bodyContentType:bodyFilename:onCompletion:] + 378
8   app                             0x00d8aea6 -[KSCrashReportSinkQuincy filterReports:onCompletion:] + 52
9   app                             0x00d83ae4 __58-[KSCrashReportFilterPipeline filterReports:onCompletion:]_block_invoke.150 + 260
10  app                             0x00d75030 kscrash_i_callCompletion + 38
11  app                             0x00d830ba __57-[KSCrashReportFilterCombine filterReports:onCompletion:]_block_invoke.97 + 654
12  app                             0x00d75030 kscrash_i_callCompletion + 38
13  app                             0x00d7d6c4 -[KSCrashReportFilterAppleFmt filterReports:onCompletion:] + 342
14  app                             0x00d82f60 __57-[KSCrashReportFilterCombine filterReports:onCompletion:]_block_invoke.97 + 308
15  app                             0x00d75030 kscrash_i_callCompletion + 38
16  app                             0x00d823fe -[KSCrashReportFilterPassthrough filterReports:onCompletion:] + 22
17  app                             0x00d82be8 -[KSCrashReportFilterCombine filterReports:onCompletion:] + 652
18  app                             0x00d8387e -[KSCrashReportFilterPipeline filterReports:onCompletion:] + 530
19  app                             0x00d83ae4 __58-[KSCrashReportFilterPipeline filterReports:onCompletion:]_block_invoke.150 + 260
20  app                             0x00d75030 kscrash_i_callCompletion + 38
21  app                             0x00d838e4 -[KSCrashReportFilterPipeline filterReports:onCompletion:] + 632
22  app                             0x00d8387e -[KSCrashReportFilterPipeline filterReports:onCompletion:] + 530
23  app                             0x00d81d46 -[KSCrash sendReports:onCompletion:] + 176
24  app                             0x00d817f2 -[KSCrash sendAllReportsWithCompletion:] + 278
25  app                             0x00d93854 -[KSCrashInstallation sendAllReportsWithCompletion:] + 260
26  app                             0x00494d2a -[AppDelegate application:didFinishLaunchingWithOptions:] (AppDelegate.mm:150)
27  UIKit                           0x33fa3a9c -[UIApplication _handleDelegateCallbacksWithOptions:isSuspended:restoreState:] + 248
28  UIKit                           0x33fa3620 -[UIApplication _callInitializationDelegatesForURL:payload:suspended:] + 1164
29  UIKit                           0x33f9b82e -[UIApplication _runWithURL:payload:launchOrientation:statusBarStyle:statusBarHidden:] + 694
30  UIKit                           0x33f43d1a -[UIApplication handleEvent:withNewEvent:] + 1006
31  UIKit                           0x33f437a8 -[UIApplication sendEvent:] + 68
32  UIKit                           0x33f431ea _UIApplicationHandleEvent + 6194
33  GraphicsServices                0x35c5b5f2 _PurpleEventCallback + 586
34  GraphicsServices                0x35c5b222 PurpleEventCallback + 30
35  CoreFoundation                  0x321093e2 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 30
36  CoreFoundation                  0x32109386 __CFRunLoopDoSource1 + 134
37  CoreFoundation                  0x3210820a __CFRunLoopRun + 1378
38  CoreFoundation                  0x3207b238 CFRunLoopRunSpecific + 352
39  CoreFoundation                  0x3207b0c4 CFRunLoopRunInMode + 100
40  UIKit                           0x33f9a468 -[UIApplication _run] + 664
41  UIKit                           0x33f972b4 UIApplicationMain + 1116
42  app                             0x004a766a main (main.m:16)
43  libdyld.dylib                   0x3a25cb1c tlv_initializer + 4

this crash is based on version 1.5.2.

@kstenerud
Copy link
Owner

Please test it on the latest version first, as [NSString(URLEncode) URLEncoded] has been replaced with toStringWithQuotesEscaped, so the problem might already be solved.

The error you posted is happening because a non-string is being passed to URLEncoded. If you encounter the problem with toStringWithQuotesEscaped as well, you should try printing out the "string" that was passed in to see what it really is.

@recih
Copy link
Author

recih commented Jun 7, 2016

OK, forget this pull request.

But if a non-string is being passed to toStringWithQuotesEscaped, it will crash too, isn't it?

@kstenerud
Copy link
Owner

Yes, but the more important question is what non-string is being passed to it and why. If you encounter the crash in the latest version, please put an NSLog in toStringWithQuotesEscaped to print out what is being passed in. That will give an idea of what's actually happening.

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.

None yet

2 participants