Title: [232236] trunk/Source
Revision
232236
Author
[email protected]
Date
2018-05-27 21:21:09 -0700 (Sun, 27 May 2018)

Log Message

[iOS] Fix warnings about leaks found by clang static analyzer
<https://webkit.org/b/186009>
<rdar://problem/40574267>

Reviewed by Daniel Bates.

Source/ThirdParty/libwebrtc:

* Source/third_party/opus/src/src/opus_compare.c:
* Source/third_party/opus/src/src/opus_demo.c:
(main):
- Free allocated memory on early returns.
* Source/third_party/usrsctp/usrsctplib/user_mbuf.c:
(clust_constructor_dup):
(mb_ctor_clust):
- Free allocated memory if `m` is NULL.
* Source/third_party/usrsctp/usrsctplib/user_socket.c:
(usrsctp_connect): Free `sa` memory if getsockaddr() returns an
error, but still allocates memory for `sa`.
* WebKit/patch-opus.diff: Add patch for opus changes.
* WebKit/patch-usrsctp: Rename empty file to patch-usrsctp.diff.
* WebKit/patch-usrsctp.diff: Add patch for usrsctp changes.
* libwebrtc.xcodeproj/project.pbxproj: Remove opus_compare.c,
opus_demo.c, and repacketizer_demo.c from opus target.  This
code is for stand-alone tools, and although it may be removed
during dead code linking, we don't need to spend time compiling
it.

Source/WebCore:

* Modules/webauthn/cocoa/LocalAuthenticator.mm:
(WebCore::LocalAuthenticator::makeCredential):
(WebCore::LocalAuthenticator::getAssertion):
(WebCore::LocalAuthenticator::issueClientCertificate const):
- Don't leak CF objects in early return paths, and get rid of
  `retained*` variables, by making original variables use
  RetainPtr<>.
* bridge/objc/WebScriptObject.mm:
(+[WebUndefined allocWithZone:]): Modernize WebUndefined by
using NeverDestroyed<RetainPr<WebUndefined>> type.  Explicitly
retain the object returned on each call.
(+[WebUndefined undefined]): Explicitly autorelease the object
returned.  Note that neither of these changes fixes the static
analyzer warnings in this source file.
* platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm:
(WebCore::exernalDeviceDisplayNameForPlayer): Use RetainPtr<> to
stop leaking NSString objects in a loop.
* platform/ios/wak/WAKWindow.h:
(-[WAKWindow _newFirstResponderAfterResigning]): Mark as
NS_RETURNS_NOT_RETAINED like the corresponding AppKit method
since this doesn't return a new object.  This fixes some
false-positive leaks warnings.

Source/WebKit:

* UIProcess/Automation/ios/WebAutomationSessionIOS.mm:
(WebKit::WebAutomationSession::platformSimulateKeySequence): Fix
leak of two WebEvent objects that happened in a loop.
* UIProcess/Cocoa/SystemPreviewControllerCocoa.mm:
(-[_WKPreviewControllerDelegate previewController:transitionImageForPreviewItem:contentRect:]):
Fix leak of a UIImage.

Source/WebKitLegacy/mac:

* WebView/WebHTMLView.mm:
(-[WebHTMLView doCommandBySelector:]): Fix use of an
uninitialized boolean variable (`eventWasHandled`) that only
happened on iOS.

Modified Paths

Added Paths

Removed Paths

Diff

Modified: trunk/Source/ThirdParty/libwebrtc/ChangeLog (232235 => 232236)


--- trunk/Source/ThirdParty/libwebrtc/ChangeLog	2018-05-28 04:17:47 UTC (rev 232235)
+++ trunk/Source/ThirdParty/libwebrtc/ChangeLog	2018-05-28 04:21:09 UTC (rev 232236)
@@ -1,3 +1,31 @@
+2018-05-27  David Kilzer  <[email protected]>
+
+        [iOS] Fix warnings about leaks found by clang static analyzer
+        <https://webkit.org/b/186009>
+        <rdar://problem/40574267>
+
+        Reviewed by Daniel Bates.
+
+        * Source/third_party/opus/src/src/opus_compare.c:
+        * Source/third_party/opus/src/src/opus_demo.c:
+        (main):
+        - Free allocated memory on early returns.
+        * Source/third_party/usrsctp/usrsctplib/user_mbuf.c:
+        (clust_constructor_dup):
+        (mb_ctor_clust):
+        - Free allocated memory if `m` is NULL.
+        * Source/third_party/usrsctp/usrsctplib/user_socket.c:
+        (usrsctp_connect): Free `sa` memory if getsockaddr() returns an
+        error, but still allocates memory for `sa`.
+        * WebKit/patch-opus.diff: Add patch for opus changes.
+        * WebKit/patch-usrsctp: Rename empty file to patch-usrsctp.diff.
+        * WebKit/patch-usrsctp.diff: Add patch for usrsctp changes.
+        * libwebrtc.xcodeproj/project.pbxproj: Remove opus_compare.c,
+        opus_demo.c, and repacketizer_demo.c from opus target.  This
+        code is for stand-alone tools, and although it may be removed
+        during dead code linking, we don't need to spend time compiling
+        it.
+
 2018-05-07  Youenn Fablet  <[email protected]>
 
         Activate ARC for libwebrtc Objective C files

Modified: trunk/Source/ThirdParty/libwebrtc/Source/third_party/opus/src/src/opus_compare.c (232235 => 232236)


--- trunk/Source/ThirdParty/libwebrtc/Source/third_party/opus/src/src/opus_compare.c	2018-05-28 04:17:47 UTC (rev 232235)
+++ trunk/Source/ThirdParty/libwebrtc/Source/third_party/opus/src/src/opus_compare.c	2018-05-28 04:21:09 UTC (rev 232236)
@@ -238,11 +238,15 @@
   if(xlength!=ylength*downsample){
     fprintf(stderr,"Sample counts do not match (%lu!=%lu).\n",
      (unsigned long)xlength,(unsigned long)ylength*downsample);
+    free(x);
+    free(y);
     return EXIT_FAILURE;
   }
   if(xlength<TEST_WIN_SIZE){
     fprintf(stderr,"Insufficient sample data (%lu<%i).\n",
      (unsigned long)xlength,TEST_WIN_SIZE);
+    free(x);
+    free(y);
     return EXIT_FAILURE;
   }
   nframes=(xlength-TEST_WIN_SIZE+TEST_WIN_STEP)/TEST_WIN_STEP;

Modified: trunk/Source/ThirdParty/libwebrtc/Source/third_party/opus/src/src/opus_demo.c (232235 => 232236)


--- trunk/Source/ThirdParty/libwebrtc/Source/third_party/opus/src/src/opus_demo.c	2018-05-28 04:17:47 UTC (rev 232235)
+++ trunk/Source/ThirdParty/libwebrtc/Source/third_party/opus/src/src/opus_demo.c	2018-05-28 04:21:09 UTC (rev 232236)
@@ -721,8 +721,14 @@
             if (len[toggle] < 0)
             {
                 fprintf (stderr, "opus_encode() returned %d\n", len[toggle]);
+                free(data[0]);
+                if (use_inbandfec)
+                    free(data[1]);
                 fclose(fin);
                 fclose(fout);
+                free(in);
+                free(out);
+                free(fbytes);
                 return EXIT_FAILURE;
             }
             curr_mode_count += frame_size;
@@ -740,6 +746,14 @@
            if ((err = opus_packet_pad(data[toggle], len[toggle], new_len)) != OPUS_OK)
            {
               fprintf(stderr, "padding failed: %s\n", opus_strerror(err));
+              free(data[0]);
+              if (use_inbandfec)
+                  free(data[1]);
+              fclose(fin);
+              fclose(fout);
+              free(in);
+              free(out);
+              free(fbytes);
               return EXIT_FAILURE;
            }
            len[toggle] = new_len;
@@ -751,15 +765,39 @@
             int_to_char(len[toggle], int_field);
             if (fwrite(int_field, 1, 4, fout) != 4) {
                fprintf(stderr, "Error writing.\n");
+               free(data[0]);
+               if (use_inbandfec)
+                   free(data[1]);
+               fclose(fin);
+               fclose(fout);
+               free(in);
+               free(out);
+               free(fbytes);
                return EXIT_FAILURE;
             }
             int_to_char(enc_final_range[toggle], int_field);
             if (fwrite(int_field, 1, 4, fout) != 4) {
                fprintf(stderr, "Error writing.\n");
+               free(data[0]);
+               if (use_inbandfec)
+                   free(data[1]);
+               fclose(fin);
+               fclose(fout);
+               free(in);
+               free(out);
+               free(fbytes);
                return EXIT_FAILURE;
             }
             if (fwrite(data[toggle], 1, len[toggle], fout) != (unsigned)len[toggle]) {
                fprintf(stderr, "Error writing.\n");
+               free(data[0]);
+               if (use_inbandfec)
+                   free(data[1]);
+               fclose(fin);
+               fclose(fout);
+               free(in);
+               free(out);
+               free(fbytes);
                return EXIT_FAILURE;
             }
             tot_samples += nb_encoded;
@@ -803,6 +841,14 @@
                        }
                        if (fwrite(fbytes, sizeof(short)*channels, output_samples-skip, fout) != (unsigned)(output_samples-skip)){
                           fprintf(stderr, "Error writing.\n");
+                          free(data[0]);
+                          if (use_inbandfec)
+                              free(data[1]);
+                          fclose(fin);
+                          fclose(fout);
+                          free(in);
+                          free(out);
+                          free(fbytes);
                           return EXIT_FAILURE;
                        }
                        tot_out += output_samples-skip;
@@ -829,8 +875,14 @@
                          (long)count,
                          (unsigned long)enc_final_range[toggle^use_inbandfec],
                          (unsigned long)dec_final_range);
+            free(data[0]);
+            if (use_inbandfec)
+                free(data[1]);
             fclose(fin);
             fclose(fout);
+            free(in);
+            free(out);
+            free(fbytes);
             return EXIT_FAILURE;
         }
 

Modified: trunk/Source/ThirdParty/libwebrtc/Source/third_party/usrsctp/usrsctplib/user_mbuf.c (232235 => 232236)


--- trunk/Source/ThirdParty/libwebrtc/Source/third_party/usrsctp/usrsctplib/user_mbuf.c	2018-05-28 04:17:47 UTC (rev 232235)
+++ trunk/Source/ThirdParty/libwebrtc/Source/third_party/usrsctp/usrsctplib/user_mbuf.c	2018-05-28 04:21:09 UTC (rev 232236)
@@ -232,7 +232,8 @@
 		m->m_ext.ext_size = size;
 		m->m_ext.ext_type = type;
 		m->m_ext.ref_cnt = refcnt;
-	}
+	} else
+		SCTP_ZONE_FREE(zone_ext_refcnt, refcnt);
 
 	return (0);
 }
@@ -527,7 +528,8 @@
 		m->m_ext.ext_size = size;
 		m->m_ext.ext_type = type;
 		m->m_ext.ref_cnt = refcnt;
-	}
+	} else
+		SCTP_ZONE_FREE(zone_ext_refcnt, refcnt);
 #endif
 	return (0);
 }

Modified: trunk/Source/ThirdParty/libwebrtc/Source/third_party/usrsctp/usrsctplib/user_socket.c (232235 => 232236)


--- trunk/Source/ThirdParty/libwebrtc/Source/third_party/usrsctp/usrsctplib/user_socket.c	2018-05-28 04:17:47 UTC (rev 232235)
+++ trunk/Source/ThirdParty/libwebrtc/Source/third_party/usrsctp/usrsctplib/user_socket.c	2018-05-28 04:21:09 UTC (rev 232236)
@@ -2131,11 +2131,14 @@
 
 int usrsctp_connect(struct socket *so, struct sockaddr *name, int namelen)
 {
-	struct sockaddr *sa;
+	struct sockaddr *sa = NULL;
 
 	errno = getsockaddr(&sa, (caddr_t)name, namelen);
-	if (errno)
+	if (errno) {
+		if (sa)
+			FREE(sa, M_SONAME);
 		return (-1);
+	}
 
 	errno = user_connect(so, sa);
 	FREE(sa, M_SONAME);

Added: trunk/Source/ThirdParty/libwebrtc/WebKit/patch-opus.diff (0 => 232236)


--- trunk/Source/ThirdParty/libwebrtc/WebKit/patch-opus.diff	                        (rev 0)
+++ trunk/Source/ThirdParty/libwebrtc/WebKit/patch-opus.diff	2018-05-28 04:21:09 UTC (rev 232236)
@@ -0,0 +1,124 @@
+diff --git a/Source/ThirdParty/libwebrtc/Source/third_party/opus/src/src/opus_compare.c b/Source/ThirdParty/libwebrtc/Source/third_party/opus/src/src/opus_compare.c
+index 06c67d752f7..66828fd8cae 100644
+--- a/Source/ThirdParty/libwebrtc/Source/third_party/opus/src/src/opus_compare.c
++++ b/Source/ThirdParty/libwebrtc/Source/third_party/opus/src/src/opus_compare.c
+@@ -238,11 +238,15 @@ int main(int _argc,const char **_argv){
+   if(xlength!=ylength*downsample){
+     fprintf(stderr,"Sample counts do not match (%lu!=%lu).\n",
+      (unsigned long)xlength,(unsigned long)ylength*downsample);
++    free(x);
++    free(y);
+     return EXIT_FAILURE;
+   }
+   if(xlength<TEST_WIN_SIZE){
+     fprintf(stderr,"Insufficient sample data (%lu<%i).\n",
+      (unsigned long)xlength,TEST_WIN_SIZE);
++    free(x);
++    free(y);
+     return EXIT_FAILURE;
+   }
+   nframes=(xlength-TEST_WIN_SIZE+TEST_WIN_STEP)/TEST_WIN_STEP;
+diff --git a/Source/ThirdParty/libwebrtc/Source/third_party/opus/src/src/opus_demo.c b/Source/ThirdParty/libwebrtc/Source/third_party/opus/src/src/opus_demo.c
+index 7c930699d61..6988a8cb15d 100644
+--- a/Source/ThirdParty/libwebrtc/Source/third_party/opus/src/src/opus_demo.c
++++ b/Source/ThirdParty/libwebrtc/Source/third_party/opus/src/src/opus_demo.c
+@@ -721,8 +721,14 @@ int main(int argc, char *argv[])
+             if (len[toggle] < 0)
+             {
+                 fprintf (stderr, "opus_encode() returned %d\n", len[toggle]);
++                free(data[0]);
++                if (use_inbandfec)
++                    free(data[1]);
+                 fclose(fin);
+                 fclose(fout);
++                free(in);
++                free(out);
++                free(fbytes);
+                 return EXIT_FAILURE;
+             }
+             curr_mode_count += frame_size;
+@@ -740,6 +746,14 @@ int main(int argc, char *argv[])
+            if ((err = opus_packet_pad(data[toggle], len[toggle], new_len)) != OPUS_OK)
+            {
+               fprintf(stderr, "padding failed: %s\n", opus_strerror(err));
++              free(data[0]);
++              if (use_inbandfec)
++                  free(data[1]);
++              fclose(fin);
++              fclose(fout);
++              free(in);
++              free(out);
++              free(fbytes);
+               return EXIT_FAILURE;
+            }
+            len[toggle] = new_len;
+@@ -751,15 +765,39 @@ int main(int argc, char *argv[])
+             int_to_char(len[toggle], int_field);
+             if (fwrite(int_field, 1, 4, fout) != 4) {
+                fprintf(stderr, "Error writing.\n");
++               free(data[0]);
++               if (use_inbandfec)
++                   free(data[1]);
++               fclose(fin);
++               fclose(fout);
++               free(in);
++               free(out);
++               free(fbytes);
+                return EXIT_FAILURE;
+             }
+             int_to_char(enc_final_range[toggle], int_field);
+             if (fwrite(int_field, 1, 4, fout) != 4) {
+                fprintf(stderr, "Error writing.\n");
++               free(data[0]);
++               if (use_inbandfec)
++                   free(data[1]);
++               fclose(fin);
++               fclose(fout);
++               free(in);
++               free(out);
++               free(fbytes);
+                return EXIT_FAILURE;
+             }
+             if (fwrite(data[toggle], 1, len[toggle], fout) != (unsigned)len[toggle]) {
+                fprintf(stderr, "Error writing.\n");
++               free(data[0]);
++               if (use_inbandfec)
++                   free(data[1]);
++               fclose(fin);
++               fclose(fout);
++               free(in);
++               free(out);
++               free(fbytes);
+                return EXIT_FAILURE;
+             }
+             tot_samples += nb_encoded;
+@@ -803,6 +841,14 @@ int main(int argc, char *argv[])
+                        }
+                        if (fwrite(fbytes, sizeof(short)*channels, output_samples-skip, fout) != (unsigned)(output_samples-skip)){
+                           fprintf(stderr, "Error writing.\n");
++                          free(data[0]);
++                          if (use_inbandfec)
++                              free(data[1]);
++                          fclose(fin);
++                          fclose(fout);
++                          free(in);
++                          free(out);
++                          free(fbytes);
+                           return EXIT_FAILURE;
+                        }
+                        tot_out += output_samples-skip;
+@@ -829,8 +875,14 @@ int main(int argc, char *argv[])
+                          (long)count,
+                          (unsigned long)enc_final_range[toggle^use_inbandfec],
+                          (unsigned long)dec_final_range);
++            free(data[0]);
++            if (use_inbandfec)
++                free(data[1]);
+             fclose(fin);
+             fclose(fout);
++            free(in);
++            free(out);
++            free(fbytes);
+             return EXIT_FAILURE;
+         }
+ 

Deleted: trunk/Source/ThirdParty/libwebrtc/WebKit/patch-usrsctp ( => )


Added: trunk/Source/ThirdParty/libwebrtc/WebKit/patch-usrsctp.diff
===================================================================
--- trunk/Source/ThirdParty/libwebrtc/WebKit/patch-usrsctp.diff	                        (rev 0)
+++ trunk/Source/ThirdParty/libwebrtc/WebKit/patch-usrsctp.diff	2018-05-28 04:21:09 UTC (rev 232236)
@@ -0,0 +1,45 @@
+diff --git a/Source/ThirdParty/libwebrtc/Source/third_party/usrsctp/usrsctplib/user_mbuf.c b/Source/ThirdParty/libwebrtc/Source/third_party/usrsctp/usrsctplib/user_mbuf.c
+index 7a1aaba855e..3ebd8a27b6b 100644
+--- a/Source/ThirdParty/libwebrtc/Source/third_party/usrsctp/usrsctplib/user_mbuf.c
++++ b/Source/ThirdParty/libwebrtc/Source/third_party/usrsctp/usrsctplib/user_mbuf.c
+@@ -232,7 +232,8 @@ static int clust_constructor_dup(caddr_t m_clust, struct mbuf* m)
+ 		m->m_ext.ext_size = size;
+ 		m->m_ext.ext_type = type;
+ 		m->m_ext.ref_cnt = refcnt;
+-	}
++	} else
++		SCTP_ZONE_FREE(zone_ext_refcnt, refcnt);
+ 
+ 	return (0);
+ }
+@@ -527,7 +528,8 @@ mb_ctor_clust(void *mem, void *arg, int flgs)
+ 		m->m_ext.ext_size = size;
+ 		m->m_ext.ext_type = type;
+ 		m->m_ext.ref_cnt = refcnt;
+-	}
++	} else
++		SCTP_ZONE_FREE(zone_ext_refcnt, refcnt);
+ #endif
+ 	return (0);
+ }
+diff --git a/Source/ThirdParty/libwebrtc/Source/third_party/usrsctp/usrsctplib/user_socket.c b/Source/ThirdParty/libwebrtc/Source/third_party/usrsctp/usrsctplib/user_socket.c
+index a54996efdd8..b94e1e5c24a 100644
+--- a/Source/ThirdParty/libwebrtc/Source/third_party/usrsctp/usrsctplib/user_socket.c
++++ b/Source/ThirdParty/libwebrtc/Source/third_party/usrsctp/usrsctplib/user_socket.c
+@@ -2131,11 +2131,14 @@ done1:
+ 
+ int usrsctp_connect(struct socket *so, struct sockaddr *name, int namelen)
+ {
+-	struct sockaddr *sa;
++	struct sockaddr *sa = NULL;
+ 
+ 	errno = getsockaddr(&sa, (caddr_t)name, namelen);
+-	if (errno)
++	if (errno) {
++		if (sa)
++			FREE(sa, M_SONAME);
+ 		return (-1);
++	}
+ 
+ 	errno = user_connect(so, sa);
+ 	FREE(sa, M_SONAME);

Modified: trunk/Source/ThirdParty/libwebrtc/libwebrtc.xcodeproj/project.pbxproj (232235 => 232236)


--- trunk/Source/ThirdParty/libwebrtc/libwebrtc.xcodeproj/project.pbxproj	2018-05-28 04:17:47 UTC (rev 232235)
+++ trunk/Source/ThirdParty/libwebrtc/libwebrtc.xcodeproj/project.pbxproj	2018-05-28 04:21:09 UTC (rev 232236)
@@ -1260,9 +1260,7 @@
 		5C4B4AB71E42C574002651C8 /* mlp_data.c in Sources */ = {isa = PBXBuildFile; fileRef = 5C4B4A951E42C52D002651C8 /* mlp_data.c */; };
 		5C4B4AB81E42C574002651C8 /* mlp.c in Sources */ = {isa = PBXBuildFile; fileRef = 5C4B4A961E42C52D002651C8 /* mlp.c */; };
 		5C4B4AB91E42C574002651C8 /* mlp.h in Headers */ = {isa = PBXBuildFile; fileRef = 5C4B4A971E42C52D002651C8 /* mlp.h */; };
-		5C4B4ABA1E42C574002651C8 /* opus_compare.c in Sources */ = {isa = PBXBuildFile; fileRef = 5C4B4A981E42C52D002651C8 /* opus_compare.c */; };
 		5C4B4ABB1E42C574002651C8 /* opus_decoder.c in Sources */ = {isa = PBXBuildFile; fileRef = 5C4B4A991E42C52D002651C8 /* opus_decoder.c */; };
-		5C4B4ABC1E42C574002651C8 /* opus_demo.c in Sources */ = {isa = PBXBuildFile; fileRef = 5C4B4A9A1E42C52D002651C8 /* opus_demo.c */; };
 		5C4B4ABD1E42C574002651C8 /* opus_encoder.c in Sources */ = {isa = PBXBuildFile; fileRef = 5C4B4A9B1E42C52D002651C8 /* opus_encoder.c */; };
 		5C4B4ABE1E42C574002651C8 /* opus_multistream_decoder.c in Sources */ = {isa = PBXBuildFile; fileRef = 5C4B4A9C1E42C52D002651C8 /* opus_multistream_decoder.c */; };
 		5C4B4ABF1E42C574002651C8 /* opus_multistream_encoder.c in Sources */ = {isa = PBXBuildFile; fileRef = 5C4B4A9D1E42C52D002651C8 /* opus_multistream_encoder.c */; };
@@ -1269,7 +1267,6 @@
 		5C4B4AC01E42C574002651C8 /* opus_multistream.c in Sources */ = {isa = PBXBuildFile; fileRef = 5C4B4A9E1E42C52D002651C8 /* opus_multistream.c */; };
 		5C4B4AC11E42C574002651C8 /* opus_private.h in Headers */ = {isa = PBXBuildFile; fileRef = 5C4B4A9F1E42C52D002651C8 /* opus_private.h */; };
 		5C4B4AC21E42C574002651C8 /* opus.c in Sources */ = {isa = PBXBuildFile; fileRef = 5C4B4AA01E42C52D002651C8 /* opus.c */; };
-		5C4B4AC31E42C574002651C8 /* repacketizer_demo.c in Sources */ = {isa = PBXBuildFile; fileRef = 5C4B4AA11E42C52D002651C8 /* repacketizer_demo.c */; };
 		5C4B4AC41E42C574002651C8 /* repacketizer.c in Sources */ = {isa = PBXBuildFile; fileRef = 5C4B4AA21E42C52D002651C8 /* repacketizer.c */; };
 		5C4B4AC51E42C574002651C8 /* tansig_table.h in Headers */ = {isa = PBXBuildFile; fileRef = 5C4B4AA31E42C52D002651C8 /* tansig_table.h */; };
 		5C4B4C191E431F75002651C8 /* bitrate_adjuster.cc in Sources */ = {isa = PBXBuildFile; fileRef = 5C4B4C101E431F75002651C8 /* bitrate_adjuster.cc */; };
@@ -12449,9 +12446,7 @@
 				5C5F40971E978FDB00D94279 /* NSQ_del_dec_sse.c in Sources */,
 				5C5F40981E978FDB00D94279 /* NSQ_sse.c in Sources */,
 				5C4B4AC21E42C574002651C8 /* opus.c in Sources */,
-				5C4B4ABA1E42C574002651C8 /* opus_compare.c in Sources */,
 				5C4B4ABB1E42C574002651C8 /* opus_decoder.c in Sources */,
-				5C4B4ABC1E42C574002651C8 /* opus_demo.c in Sources */,
 				5C4B4ABD1E42C574002651C8 /* opus_encoder.c in Sources */,
 				5C4B4AC01E42C574002651C8 /* opus_multistream.c in Sources */,
 				5C4B4ABE1E42C574002651C8 /* opus_multistream_decoder.c in Sources */,
@@ -12472,7 +12467,6 @@
 				5CDD8F4C1E43CB1E00621E92 /* regularize_correlations_FIX.c in Sources */,
 				5CDD8EF71E43C9F600621E92 /* regularize_correlations_FLP.c in Sources */,
 				5C4B4AC41E42C574002651C8 /* repacketizer.c in Sources */,
-				5C4B4AC31E42C574002651C8 /* repacketizer_demo.c in Sources */,
 				5CDD8E811E43C80C00621E92 /* resampler.c in Sources */,
 				5CDD8E781E43C80C00621E92 /* resampler_down2.c in Sources */,
 				5CDD8E771E43C80C00621E92 /* resampler_down2_3.c in Sources */,

Modified: trunk/Source/WebCore/ChangeLog (232235 => 232236)


--- trunk/Source/WebCore/ChangeLog	2018-05-28 04:17:47 UTC (rev 232235)
+++ trunk/Source/WebCore/ChangeLog	2018-05-28 04:21:09 UTC (rev 232236)
@@ -1,3 +1,34 @@
+2018-05-27  David Kilzer  <[email protected]>
+
+        [iOS] Fix warnings about leaks found by clang static analyzer
+        <https://webkit.org/b/186009>
+        <rdar://problem/40574267>
+
+        Reviewed by Daniel Bates.
+
+        * Modules/webauthn/cocoa/LocalAuthenticator.mm:
+        (WebCore::LocalAuthenticator::makeCredential):
+        (WebCore::LocalAuthenticator::getAssertion):
+        (WebCore::LocalAuthenticator::issueClientCertificate const):
+        - Don't leak CF objects in early return paths, and get rid of
+          `retained*` variables, by making original variables use
+          RetainPtr<>.
+        * bridge/objc/WebScriptObject.mm:
+        (+[WebUndefined allocWithZone:]): Modernize WebUndefined by
+        using NeverDestroyed<RetainPr<WebUndefined>> type.  Explicitly
+        retain the object returned on each call.
+        (+[WebUndefined undefined]): Explicitly autorelease the object
+        returned.  Note that neither of these changes fixes the static
+        analyzer warnings in this source file.
+        * platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm:
+        (WebCore::exernalDeviceDisplayNameForPlayer): Use RetainPtr<> to
+        stop leaking NSString objects in a loop.
+        * platform/ios/wak/WAKWindow.h:
+        (-[WAKWindow _newFirstResponderAfterResigning]): Mark as
+        NS_RETURNS_NOT_RETAINED like the corresponding AppKit method
+        since this doesn't return a new object.  This fixes some
+        false-positive leaks warnings.
+
 2018-05-27  Dan Bernstein  <[email protected]>
 
         [Cocoa] Avoid importing directly from subumbrella frameworks

Modified: trunk/Source/WebCore/Modules/webauthn/cocoa/LocalAuthenticator.mm (232235 => 232236)


--- trunk/Source/WebCore/Modules/webauthn/cocoa/LocalAuthenticator.mm	2018-05-28 04:17:47 UTC (rev 232235)
+++ trunk/Source/WebCore/Modules/webauthn/cocoa/LocalAuthenticator.mm	2018-05-28 04:21:09 UTC (rev 232236)
@@ -296,11 +296,11 @@
                 attestedCredentialData.appendVector(credentialId);
 
                 // credentialPublicKey
-                CFDataRef publicKeyDataRef = nullptr;
+                RetainPtr<CFDataRef> publicKeyDataRef;
                 {
                     auto publicKey = adoptCF(SecKeyCopyPublicKey(privateKey));
                     CFErrorRef errorRef = nullptr;
-                    publicKeyDataRef = SecKeyCopyExternalRepresentation(publicKey.get(), &errorRef);
+                    publicKeyDataRef = adoptCF(SecKeyCopyExternalRepresentation(publicKey.get(), &errorRef));
                     auto retainError = adoptCF(errorRef);
                     if (errorRef) {
                         LOG_ERROR("Couldn't export the public key: %@", (NSError*)errorRef);
@@ -307,16 +307,15 @@
                         exceptionCallback({ UnknownError, ASCIILiteral("Unknown internal error.") });
                         return;
                     }
-                    ASSERT(((NSData *)publicKeyDataRef).length == (1 + 2*ES256KeySizeInBytes)); // 04 | X | Y
+                    ASSERT(((NSData *)publicKeyDataRef.get()).length == (1 + 2 * ES256KeySizeInBytes)); // 04 | X | Y
                 }
-                auto retainPublicKeyData = adoptCF(publicKeyDataRef);
 
                 // COSE Encoding
                 // FIXME(183535): Improve CBOR encoder to work with bytes directly.
                 Vector<uint8_t> x(ES256KeySizeInBytes);
-                [(NSData *)publicKeyDataRef getBytes: x.data() range:NSMakeRange(1, ES256KeySizeInBytes)];
+                [(NSData *)publicKeyDataRef.get() getBytes: x.data() range:NSMakeRange(1, ES256KeySizeInBytes)];
                 Vector<uint8_t> y(ES256KeySizeInBytes);
-                [(NSData *)publicKeyDataRef getBytes: y.data() range:NSMakeRange(1 + ES256KeySizeInBytes, ES256KeySizeInBytes)];
+                [(NSData *)publicKeyDataRef.get() getBytes: y.data() range:NSMakeRange(1 + ES256KeySizeInBytes, ES256KeySizeInBytes)];
                 cbor::CBORValue::MapValue publicKeyMap;
                 publicKeyMap[cbor::CBORValue(COSE::kty)] = cbor::CBORValue(COSE::EC2);
                 publicKeyMap[cbor::CBORValue(COSE::alg)] = cbor::CBORValue(COSE::ES256);
@@ -344,7 +343,7 @@
                 {
                     CFErrorRef errorRef = nullptr;
                     // FIXME(183652): Reduce prompt for biometrics
-                    CFDataRef signatureRef = SecKeyCreateSignature(privateKey, kSecKeyAlgorithmECDSASignatureMessageX962SHA256, (__bridge CFDataRef)[NSData dataWithBytes:authData.data() length:authData.size()], &errorRef);
+                    auto signatureRef = adoptCF(SecKeyCreateSignature(privateKey, kSecKeyAlgorithmECDSASignatureMessageX962SHA256, (__bridge CFDataRef)[NSData dataWithBytes:authData.data() length:authData.size()], &errorRef));
                     auto retainError = adoptCF(errorRef);
                     if (errorRef) {
                         LOG_ERROR("Couldn't generate the signature: %@", (NSError*)errorRef);
@@ -351,8 +350,7 @@
                         exceptionCallback({ UnknownError, ASCIILiteral("Unknown internal error.") });
                         return;
                     }
-                    auto retainSignature = adoptCF(signatureRef);
-                    NSData *nsSignature = (NSData *)signatureRef;
+                    auto nsSignature = (NSData *)signatureRef.get();
                     signature.append(reinterpret_cast<const uint8_t*>(nsSignature.bytes), nsSignature.length);
                 }
                 attestationStatementMap[cbor::CBORValue("alg")] = cbor::CBORValue(COSE::ES256);
@@ -502,7 +500,7 @@
 
             CFErrorRef errorRef = nullptr;
             // FIXME: Converting CFTypeRef to SecKeyRef is quite subtle here.
-            CFDataRef signatureRef = SecKeyCreateSignature((__bridge SecKeyRef)((id)privateKeyRef), kSecKeyAlgorithmECDSASignatureMessageX962SHA256, (__bridge CFDataRef)dataToSign, &errorRef);
+            auto signatureRef = adoptCF(SecKeyCreateSignature((__bridge SecKeyRef)((id)privateKeyRef), kSecKeyAlgorithmECDSASignatureMessageX962SHA256, (__bridge CFDataRef)dataToSign, &errorRef));
             auto retainError = adoptCF(errorRef);
             if (errorRef) {
                 LOG_ERROR("Couldn't generate the signature: %@", (NSError*)errorRef);
@@ -509,8 +507,7 @@
                 exceptionCallback({ UnknownError, ASCIILiteral("Unknown internal error.") });
                 return;
             }
-            auto retainSignature = adoptCF(signatureRef);
-            NSData *nsSignature = (NSData *)signatureRef;
+            auto nsSignature = (NSData *)signatureRef.get();
             signature.append(reinterpret_cast<const uint8_t*>(nsSignature.bytes), nsSignature.length);
         }
 
@@ -554,10 +551,10 @@
     // Apple Attestation
     ASSERT(hash.size() <= 32);
 
-    SecAccessControlRef accessControlRef;
+    RetainPtr<SecAccessControlRef> accessControlRef;
     {
         CFErrorRef errorRef = nullptr;
-        accessControlRef = SecAccessControlCreateWithFlags(NULL, kSecAttrAccessibleWhenPasscodeSetThisDeviceOnly, kSecAccessControlPrivateKeyUsage | kSecAccessControlUserPresence, &errorRef);
+        accessControlRef = adoptCF(SecAccessControlCreateWithFlags(NULL, kSecAttrAccessibleWhenPasscodeSetThisDeviceOnly, kSecAccessControlPrivateKeyUsage | kSecAccessControlUserPresence, &errorRef));
         auto retainError = adoptCF(errorRef);
         if (errorRef) {
             LOG_ERROR("Couldn't create ACL: %@", (NSError *)errorRef);
@@ -565,7 +562,6 @@
             return;
         }
     }
-    auto retainAccessControl = adoptCF(accessControlRef);
 
     String label(username);
     label.append("@" + rpId);
@@ -578,7 +574,7 @@
         kMAOptionsBAAValidity: @(1440), // Last one day.
         kMAOptionsBAASCRTAttestation: @(NO),
         kMAOptionsBAANonce: [NSData dataWithBytes:hash.data() length:hash.size()],
-        kMAOptionsBAAAccessControls: (id)accessControlRef,
+        kMAOptionsBAAAccessControls: (id)accessControlRef.get(),
         kMAOptionsBAAOIDSToInclude: @[kMAOptionsBAAOIDNonce]
     };
 

Modified: trunk/Source/WebCore/bridge/objc/WebScriptObject.mm (232235 => 232236)


--- trunk/Source/WebCore/bridge/objc/WebScriptObject.mm	2018-05-28 04:17:47 UTC (rev 232235)
+++ trunk/Source/WebCore/bridge/objc/WebScriptObject.mm	2018-05-28 04:21:09 UTC (rev 232236)
@@ -656,10 +656,10 @@
 {
     UNUSED_PARAM(unusedZone);
 
-    static WebUndefined *sharedUndefined = 0;
-    if (!sharedUndefined)
-        sharedUndefined = [super allocWithZone:NULL];
-    return sharedUndefined;
+    static NeverDestroyed<RetainPtr<WebUndefined>> sharedUndefined;
+    if (!sharedUndefined.get())
+        sharedUndefined.get() = adoptNS([super allocWithZone:nullptr]);
+    return [sharedUndefined.get() retain];
 }
 
 - (NSString *)description
@@ -715,7 +715,7 @@
 
 + (WebUndefined *)undefined
 {
-    return [WebUndefined allocWithZone:NULL];
+    return [[WebUndefined allocWithZone:NULL] autorelease];
 }
 
 @end

Modified: trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm (232235 => 232236)


--- trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm	2018-05-28 04:17:47 UTC (rev 232235)
+++ trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm	2018-05-28 04:21:09 UTC (rev 232236)
@@ -2802,8 +2802,10 @@
             return [outputContext deviceName];
 
         auto outputDeviceNames = adoptNS([[NSMutableArray alloc] init]);
-        for (AVOutputDevice *outputDevice in [outputContext outputDevices])
-            [outputDeviceNames addObject:[[outputDevice name] copy]];
+        for (AVOutputDevice *outputDevice in [outputContext outputDevices]) {
+            auto outputDeviceName = adoptNS([[outputDevice name] copy]);
+            [outputDeviceNames addObject:outputDeviceName.get()];
+        }
 
         return [outputDeviceNames componentsJoinedByString:@" + "];
     }

Modified: trunk/Source/WebCore/platform/ios/wak/WAKWindow.h (232235 => 232236)


--- trunk/Source/WebCore/platform/ios/wak/WAKWindow.h	2018-05-28 04:17:47 UTC (rev 232235)
+++ trunk/Source/WebCore/platform/ios/wak/WAKWindow.h	2018-05-28 04:21:09 UTC (rev 232236)
@@ -116,7 +116,7 @@
 - (void)setVisible:(BOOL)visible;
 - (NSSelectionDirection)keyViewSelectionDirection;
 - (BOOL)makeFirstResponder:(NSResponder *)aResponder;
-- (WAKView *)_newFirstResponderAfterResigning;
+- (WAKView *)_newFirstResponderAfterResigning NS_RETURNS_NOT_RETAINED;
 - (void)setFrame:(NSRect)frameRect display:(BOOL)flag;
 - (CGRect)frame;
 - (void)setContentRect:(CGRect)rect;

Modified: trunk/Source/WebKit/ChangeLog (232235 => 232236)


--- trunk/Source/WebKit/ChangeLog	2018-05-28 04:17:47 UTC (rev 232235)
+++ trunk/Source/WebKit/ChangeLog	2018-05-28 04:21:09 UTC (rev 232236)
@@ -1,3 +1,18 @@
+2018-05-27  David Kilzer  <[email protected]>
+
+        [iOS] Fix warnings about leaks found by clang static analyzer
+        <https://webkit.org/b/186009>
+        <rdar://problem/40574267>
+
+        Reviewed by Daniel Bates.
+
+        * UIProcess/Automation/ios/WebAutomationSessionIOS.mm:
+        (WebKit::WebAutomationSession::platformSimulateKeySequence): Fix
+        leak of two WebEvent objects that happened in a loop.
+        * UIProcess/Cocoa/SystemPreviewControllerCocoa.mm:
+        (-[_WKPreviewControllerDelegate previewController:transitionImageForPreviewItem:contentRect:]):
+        Fix leak of a UIImage.
+
 2018-05-27  Dan Bernstein  <[email protected]>
 
         [Cocoa] Avoid importing directly from subumbrella frameworks

Modified: trunk/Source/WebKit/UIProcess/Automation/ios/WebAutomationSessionIOS.mm (232235 => 232236)


--- trunk/Source/WebKit/UIProcess/Automation/ios/WebAutomationSessionIOS.mm	2018-05-28 04:17:47 UTC (rev 232235)
+++ trunk/Source/WebKit/UIProcess/Automation/ios/WebAutomationSessionIOS.mm	2018-05-28 04:21:09 UTC (rev 232236)
@@ -163,8 +163,10 @@
     BOOL isTabKey = [text isEqualToString:@"\t"];
 
     [text enumerateSubstringsInRange:NSMakeRange(0, text.length) options:NSStringEnumerationByComposedCharacterSequences usingBlock:^(NSString *substring, NSRange substringRange, NSRange enclosingRange, BOOL *stop) {
-        [eventsToBeSent addObject:[[::WebEvent alloc] initWithKeyEventType:WebEventKeyDown timeStamp:CFAbsoluteTimeGetCurrent() characters:substring charactersIgnoringModifiers:substring modifiers:m_currentModifiers isRepeating:NO withFlags:0 withInputManagerHint:nil keyCode:0 isTabKey:isTabKey]];
-        [eventsToBeSent addObject:[[::WebEvent alloc] initWithKeyEventType:WebEventKeyUp timeStamp:CFAbsoluteTimeGetCurrent() characters:substring charactersIgnoringModifiers:substring modifiers:m_currentModifiers isRepeating:NO withFlags:0 withInputManagerHint:nil keyCode:0 isTabKey:isTabKey]];
+        auto keyDownEvent = adoptNS([[::WebEvent alloc] initWithKeyEventType:WebEventKeyDown timeStamp:CFAbsoluteTimeGetCurrent() characters:substring charactersIgnoringModifiers:substring modifiers:m_currentModifiers isRepeating:NO withFlags:0 withInputManagerHint:nil keyCode:0 isTabKey:isTabKey]);
+        [eventsToBeSent addObject:keyDownEvent.get()];
+        auto keyUpEvent = adoptNS([[::WebEvent alloc] initWithKeyEventType:WebEventKeyUp timeStamp:CFAbsoluteTimeGetCurrent() characters:substring charactersIgnoringModifiers:substring modifiers:m_currentModifiers isRepeating:NO withFlags:0 withInputManagerHint:nil keyCode:0 isTabKey:isTabKey]);
+        [eventsToBeSent addObject:keyUpEvent.get()];
     }];
 
     sendSynthesizedEventsToPage(page, eventsToBeSent.get());

Modified: trunk/Source/WebKit/UIProcess/Cocoa/SystemPreviewControllerCocoa.mm (232235 => 232236)


--- trunk/Source/WebKit/UIProcess/Cocoa/SystemPreviewControllerCocoa.mm	2018-05-28 04:17:47 UTC (rev 232235)
+++ trunk/Source/WebKit/UIProcess/Cocoa/SystemPreviewControllerCocoa.mm	2018-05-28 04:21:09 UTC (rev 232236)
@@ -183,7 +183,7 @@
         }
     }
 
-    return [UIImage new];
+    return [[UIImage new] autorelease];
 }
 
 @end

Modified: trunk/Source/WebKitLegacy/mac/ChangeLog (232235 => 232236)


--- trunk/Source/WebKitLegacy/mac/ChangeLog	2018-05-28 04:17:47 UTC (rev 232235)
+++ trunk/Source/WebKitLegacy/mac/ChangeLog	2018-05-28 04:21:09 UTC (rev 232236)
@@ -1,3 +1,16 @@
+2018-05-27  David Kilzer  <[email protected]>
+
+        [iOS] Fix warnings about leaks found by clang static analyzer
+        <https://webkit.org/b/186009>
+        <rdar://problem/40574267>
+
+        Reviewed by Daniel Bates.
+
+        * WebView/WebHTMLView.mm:
+        (-[WebHTMLView doCommandBySelector:]): Fix use of an
+        uninitialized boolean variable (`eventWasHandled`) that only
+        happened on iOS.
+
 2018-05-27  Dan Bernstein  <[email protected]>
 
         [Cocoa] Avoid importing directly from subumbrella frameworks

Modified: trunk/Source/WebKitLegacy/mac/WebView/WebHTMLView.mm (232235 => 232236)


--- trunk/Source/WebKitLegacy/mac/WebView/WebHTMLView.mm	2018-05-28 04:17:47 UTC (rev 232235)
+++ trunk/Source/WebKitLegacy/mac/WebView/WebHTMLView.mm	2018-05-28 04:21:09 UTC (rev 232236)
@@ -6754,8 +6754,8 @@
             Editor::Command command = [self coreCommandBySelector:selector];
             if (command.isSupported())
                 eventWasHandled = command.execute(event);
+            else {
 #if PLATFORM(MAC)
-            else {
                 // If WebKit does not support this command, we need to pass the selector to super.
                 _private->selectorForDoCommandBySelector = selector;
 
@@ -6767,8 +6767,10 @@
                 [sink detach];
 
                 _private->selectorForDoCommandBySelector = 0;
+#else
+                eventWasHandled = false;
+#endif
             }
-#endif
         }
 
         if (parameters)
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to