Bug 1317726 - sdp_file_parser should not depend on xpcom glue; r=drno
authorDan Minor <dminor@mozilla.com>
Tue, 15 Nov 2016 11:53:47 -0500
changeset 324268 3a36e60d1c4ce25062d843d6cabd970c4c9cc84d
parent 324267 b368ec57dc57d5fc4edd00c4c505fe52d10ad160
child 324269 3e61ea3cb8375424b2d4363e9a09cb0538f14cc9
push id24
push usermaklebus@msu.edu
push dateTue, 20 Dec 2016 03:11:33 +0000
reviewersdrno
bugs1317726
milestone53.0a1
Bug 1317726 - sdp_file_parser should not depend on xpcom glue; r=drno MozReview-Commit-ID: KDv3RzGurQx
media/webrtc/signaling/fuzztest/moz.build
media/webrtc/signaling/fuzztest/sdp_file_parser.cpp
media/webrtc/signaling/src/sdp/sipcc/cpr_string.c
python/mozbuild/mozbuild/frontend/emitter.py
--- a/media/webrtc/signaling/fuzztest/moz.build
+++ b/media/webrtc/signaling/fuzztest/moz.build
@@ -1,32 +1,32 @@
 # -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*-
 # vim: set filetype=python:
 # This Source Code Form is subject to the terms of the Mozilla Public
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
-
-if CONFIG['OS_TARGET'] != 'WINNT' and CONFIG['MOZ_WIDGET_TOOLKIT'] != 'gonk' and CONFIG['MOZ_WIDGET_TOOLKIT'] != 'uikit':
+if CONFIG['OS_TARGET'] == 'Linux' or CONFIG['OS_TARGET'] == 'Darwin':
     DISABLE_STL_WRAPPING = True
+    DEFINES['CPR_STRING_USE_FALLIBLE_MALLOC'] = True
     DEFINES['MOZ_NO_MOZALLOC'] = True
 
     if CONFIG['OS_TARGET'] == 'Darwin':
         DEFINES['SIP_OS_OSX'] = True
     else:
         DEFINES['SIP_OS_LINUX'] = True
 
     LOCAL_INCLUDES += [
         '../..',
         '/media/mtransport',
         '/media/webrtc/signaling/src/common/browser_logging',
     ]
 
     USE_LIBS += [
         '/media/webrtc/trunk/testing/gtest_gtest/gtest',
-        'nspr'
+        'nspr',
     ]
 
     SOURCES = [
       '/media/webrtc/signaling/src/sdp/SdpAttribute.cpp',
       '/media/webrtc/signaling/src/sdp/SdpHelper.cpp',
       '/media/webrtc/signaling/src/sdp/SdpMediaSection.cpp',
       '/media/webrtc/signaling/src/sdp/sipcc/cpr_string.c',
       '/media/webrtc/signaling/src/sdp/sipcc/sdp_access.c',
@@ -40,9 +40,9 @@ if CONFIG['OS_TARGET'] != 'WINNT' and CO
       '/media/webrtc/signaling/src/sdp/sipcc/sdp_utils.c',
       '/media/webrtc/signaling/src/sdp/SipccSdp.cpp',
       '/media/webrtc/signaling/src/sdp/SipccSdpAttributeList.cpp',
       '/media/webrtc/signaling/src/sdp/SipccSdpMediaSection.cpp',
       '/media/webrtc/signaling/src/sdp/SipccSdpParser.cpp',
       'sdp_file_parser.cpp',
     ]
 
-    GeckoProgram('sdp_file_parser')
+    Program('sdp_file_parser')
--- a/media/webrtc/signaling/fuzztest/sdp_file_parser.cpp
+++ b/media/webrtc/signaling/fuzztest/sdp_file_parser.cpp
@@ -21,16 +21,26 @@ void CSFLog(CSFLogLevel priority, const 
   va_start(ap, format);
 
   printf("%s\n:", tag);
   vprintf(format, ap);
 
   va_end(ap);
 }
 
+extern "C" {
+void NS_DebugBreak(uint32_t aSeverity,
+                   const char* aStr, const char* aExpr,
+                   const char* aFile, int32_t aLine)
+{
+  fprintf(stderr, "NS_DebugBreak: %u %s %s %s %u", aSeverity, aStr, aExpr,
+          aFile, aLine);
+}
+} // end extern "C".
+
 namespace mozilla {
 
 enum class LogLevel {
 
 };
 
 namespace detail {
 
--- a/media/webrtc/signaling/src/sdp/sipcc/cpr_string.c
+++ b/media/webrtc/signaling/src/sdp/sipcc/cpr_string.c
@@ -5,23 +5,29 @@
 #include <stdarg.h>
 
 #include "mozilla/Assertions.h"
 #include "cpr_types.h"
 #include "cpr_string.h"
 #include "cpr_strings.h"
 
 /* From cpr_stdlib.h */
+#ifdef CPR_STRING_USE_FALLIBLE_MALLOC
+#define cpr_malloc(a) malloc(a)
+#define cpr_calloc(a, b) calloc(a, b)
+#define cpr_realloc(a, b) realloc(a, b)
+#define cpr_free(a) free(a)
+#else
 #include "mozilla/mozalloc.h"
 
 #define cpr_malloc(a) moz_xmalloc(a)
 #define cpr_calloc(a, b) moz_xcalloc(a, b)
 #define cpr_realloc(a, b) moz_xrealloc(a, b)
 #define cpr_free(a) free(a)
-
+#endif
 
 /**
  * sstrncpy
  *
  * This is Cisco's *safe* version of strncpy.  The string will always
  * be NUL terminated (which is not ANSI compliant).
  *
  * Parameters: s1  - first string
--- a/python/mozbuild/mozbuild/frontend/emitter.py
+++ b/python/mozbuild/mozbuild/frontend/emitter.py
@@ -118,17 +118,16 @@ ALLOWED_XPCOM_GLUE = {
     ('urltest', 'netwerk/test'),
     ('TestBind', 'netwerk/test'),
     ('TestCookie', 'netwerk/test'),
     ('TestUDPSocket', 'netwerk/test'),
     ('xpcshell', 'js/xpconnect/shell'),
     ('testcrasher', 'toolkit/crashreporter/test'),
     ('mediaconduit_unittests', 'media/webrtc/signaling/test'),
     ('mediapipeline_unittest', 'media/webrtc/signaling/test'),
-    ('sdp_file_parser', 'media/webrtc/signaling/fuzztest'),
     ('signaling_unittests', 'media/webrtc/signaling/test'),
     ('TestMailCookie', 'mailnews/base/test'),
     ('calbasecomps', 'calendar/base/backend/libical/build'),
     ('purplexpcom', 'extensions/purple/purplexpcom/src'),
     ('ipdlunittest', 'ipc/ipdl/test/cxx/app'),
 }