Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 561960 | Differences between
and this patch

Collapse All | Expand All

(-)libraries/source/spidermonkey/FixBug1021171.diff (+245 lines)
Line 0 Link Here
1
# Based on
2
# HG changeset patch
3
# User Trevor Saunders <trev.saunders@gmail.com>
4
# Date 1402083090 14400
5
# Node ID fc756706366d983e5d70345cab419fbf72db3d36
6
# Parent  78c20dbe259e808fb58d65731efd4f05e8921820
7
bug 1021171 - don't return nulllptr in functions returning bool r=bz,waldo
8
9
diff --git a/js/src/builtin/TypedObject.cpp b/js/src/builtin/TypedObject.cpp
10
--- a/js/src/builtin/TypedObject.cpp
11
+++ b/js/src/builtin/TypedObject.cpp
12
@@ -705,35 +705,35 @@ ArrayMetaTypeDescr::construct(JSContext 
13
 
14
     // Construct a canonical string `new ArrayType(<elementType>)`:
15
     StringBuffer contents(cx);
16
     contents.append("new ArrayType(");
17
     contents.append(&elementType->stringRepr());
18
     contents.append(")");
19
     RootedAtom stringRepr(cx, contents.finishAtom());
20
     if (!stringRepr)
21
-        return nullptr;
22
+        return false;
23
 
24
     // Extract ArrayType.prototype
25
     RootedObject arrayTypePrototype(cx, GetPrototype(cx, arrayTypeGlobal));
26
     if (!arrayTypePrototype)
27
-        return nullptr;
28
+        return false;
29
 
30
     // Create the instance of ArrayType
31
     Rooted<UnsizedArrayTypeDescr *> obj(cx);
32
     obj = create<UnsizedArrayTypeDescr>(cx, arrayTypePrototype, elementType,
33
                                         stringRepr, 0);
34
     if (!obj)
35
         return false;
36
 
37
     // Add `length` property, which is undefined for an unsized array.
38
     if (!JSObject::defineProperty(cx, obj, cx->names().length,
39
                                   UndefinedHandleValue, nullptr, nullptr,
40
                                   JSPROP_READONLY | JSPROP_PERMANENT))
41
-        return nullptr;
42
+        return false;
43
 
44
     args.rval().setObject(*obj);
45
     return true;
46
 }
47
 
48
 /*static*/ bool
49
 UnsizedArrayTypeDescr::dimension(JSContext *cx, unsigned int argc, jsval *vp)
50
 {
51
@@ -757,30 +757,30 @@ UnsizedArrayTypeDescr::dimension(JSConte
52
     int32_t length = args[0].toInt32();
53
     Rooted<SizedTypeDescr*> elementType(cx, &unsizedTypeDescr->elementType());
54
 
55
     // Compute the size.
56
     CheckedInt32 size = CheckedInt32(elementType->size()) * length;
57
     if (!size.isValid()) {
58
         JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr,
59
                              JSMSG_TYPEDOBJECT_TOO_BIG);
60
-        return nullptr;
61
+        return false;
62
     }
63
 
64
     // Construct a canonical string `new ArrayType(<elementType>).dimension(N)`:
65
     StringBuffer contents(cx);
66
     contents.append("new ArrayType(");
67
     contents.append(&elementType->stringRepr());
68
     contents.append(").dimension(");
69
     if (!NumberValueToStringBuffer(cx, NumberValue(length), contents))
70
         return false;
71
     contents.append(")");
72
     RootedAtom stringRepr(cx, contents.finishAtom());
73
     if (!stringRepr)
74
-        return nullptr;
75
+        return false;
76
 
77
     // Create the sized type object.
78
     Rooted<SizedArrayTypeDescr*> obj(cx);
79
     obj = ArrayMetaTypeDescr::create<SizedArrayTypeDescr>(cx, unsizedTypeDescr,
80
                                                           elementType,
81
                                                           stringRepr, size.value());
82
     if (!obj)
83
         return false;
84
@@ -788,25 +788,25 @@ UnsizedArrayTypeDescr::dimension(JSConte
85
     obj->initReservedSlot(JS_DESCR_SLOT_SIZED_ARRAY_LENGTH,
86
                           Int32Value(length));
87
 
88
     // Add `length` property.
89
     RootedValue lengthVal(cx, Int32Value(length));
90
     if (!JSObject::defineProperty(cx, obj, cx->names().length,
91
                                   lengthVal, nullptr, nullptr,
92
                                   JSPROP_READONLY | JSPROP_PERMANENT))
93
-        return nullptr;
94
+        return false;
95
 
96
     // Add `unsized` property, which is a link from the sized
97
     // array to the unsized array.
98
     RootedValue unsizedTypeDescrValue(cx, ObjectValue(*unsizedTypeDescr));
99
     if (!JSObject::defineProperty(cx, obj, cx->names().unsized,
100
                                   unsizedTypeDescrValue, nullptr, nullptr,
101
                                   JSPROP_READONLY | JSPROP_PERMANENT))
102
-        return nullptr;
103
+        return false;
104
 
105
     args.rval().setObject(*obj);
106
     return true;
107
 }
108
 
109
 bool
110
 js::IsTypedObjectArray(JSObject &obj)
111
 {
112
@@ -1248,17 +1248,17 @@ DefineSimpleTypeDescr(JSContext *cx,
113
     if (!JS_DefineFunctions(cx, descr, T::typeObjectMethods))
114
         return false;
115
 
116
     // Create the typed prototype for the scalar type. This winds up
117
     // not being user accessible, but we still create one for consistency.
118
     Rooted<TypedProto*> proto(cx);
119
     proto = NewObjectWithProto<TypedProto>(cx, objProto, nullptr, TenuredObject);
120
     if (!proto)
121
-        return nullptr;
122
+        return false;
123
     proto->initTypeDescrSlot(*descr);
124
     descr->initReservedSlot(JS_DESCR_SLOT_TYPROTO, ObjectValue(*proto));
125
 
126
     RootedValue descrValue(cx, ObjectValue(*descr));
127
     if (!JSObject::defineProperty(cx, module, className,
128
                                   descrValue, nullptr, nullptr, 0))
129
     {
130
         return false;
131
@@ -1353,66 +1353,66 @@ GlobalObject::initTypedObjectModule(JSCo
132
     if (!JS_DefineFunctions(cx, module, TypedObjectMethods))
133
         return false;
134
 
135
     // uint8, uint16, any, etc
136
 
137
 #define BINARYDATA_SCALAR_DEFINE(constant_, type_, name_)                       \
138
     if (!DefineSimpleTypeDescr<ScalarTypeDescr>(cx, global, module, constant_,      \
139
                                             cx->names().name_))                 \
140
-        return nullptr;
141
+        return false;
142
     JS_FOR_EACH_SCALAR_TYPE_REPR(BINARYDATA_SCALAR_DEFINE)
143
 #undef BINARYDATA_SCALAR_DEFINE
144
 
145
 #define BINARYDATA_REFERENCE_DEFINE(constant_, type_, name_)                    \
146
     if (!DefineSimpleTypeDescr<ReferenceTypeDescr>(cx, global, module, constant_,   \
147
                                                cx->names().name_))              \
148
-        return nullptr;
149
+        return false;
150
     JS_FOR_EACH_REFERENCE_TYPE_REPR(BINARYDATA_REFERENCE_DEFINE)
151
 #undef BINARYDATA_REFERENCE_DEFINE
152
 
153
     // ArrayType.
154
 
155
     RootedObject arrayType(cx);
156
     arrayType = DefineMetaTypeDescr<ArrayMetaTypeDescr>(
157
         cx, global, module, TypedObjectModuleObject::ArrayTypePrototype);
158
     if (!arrayType)
159
-        return nullptr;
160
+        return false;
161
 
162
     RootedValue arrayTypeValue(cx, ObjectValue(*arrayType));
163
     if (!JSObject::defineProperty(cx, module, cx->names().ArrayType,
164
                                   arrayTypeValue,
165
                                   nullptr, nullptr,
166
                                   JSPROP_READONLY | JSPROP_PERMANENT))
167
-        return nullptr;
168
+        return false;
169
 
170
     // StructType.
171
 
172
     RootedObject structType(cx);
173
     structType = DefineMetaTypeDescr<StructMetaTypeDescr>(
174
         cx, global, module, TypedObjectModuleObject::StructTypePrototype);
175
     if (!structType)
176
-        return nullptr;
177
+        return false;
178
 
179
     RootedValue structTypeValue(cx, ObjectValue(*structType));
180
     if (!JSObject::defineProperty(cx, module, cx->names().StructType,
181
                                   structTypeValue,
182
                                   nullptr, nullptr,
183
                                   JSPROP_READONLY | JSPROP_PERMANENT))
184
-        return nullptr;
185
+        return false;
186
 
187
     // Everything is setup, install module on the global object:
188
     RootedValue moduleValue(cx, ObjectValue(*module));
189
     global->setConstructor(JSProto_TypedObject, moduleValue);
190
     if (!JSObject::defineProperty(cx, global, cx->names().TypedObject,
191
                                   moduleValue,
192
                                   nullptr, nullptr,
193
                                   0))
194
     {
195
-        return nullptr;
196
+        return false;
197
     }
198
 
199
     return module;
200
 }
201
 
202
 JSObject *
203
 js_InitTypedObjectModuleObject(JSContext *cx, HandleObject obj)
204
 {
205
@@ -2444,17 +2444,17 @@ TypedObject::constructUnsized(JSContext 
206
     }
207
 
208
     // Length constructor.
209
     if (args[0].isInt32()) {
210
         int32_t length = args[0].toInt32();
211
         if (length < 0) {
212
             JS_ReportErrorNumber(cx, js_GetErrorMessage,
213
                                  nullptr, JSMSG_TYPEDOBJECT_BAD_ARGS);
214
-            return nullptr;
215
+            return false;
216
         }
217
         Rooted<TypedObject*> obj(cx, createZeroed(cx, callee, length));
218
         if (!obj)
219
             return false;
220
         args.rval().setObject(*obj);
221
         return true;
222
     }
223
 
224
diff --git a/js/src/frontend/BytecodeCompiler.cpp b/js/src/frontend/BytecodeCompiler.cpp
225
--- a/js/src/frontend/BytecodeCompiler.cpp
226
+++ b/js/src/frontend/BytecodeCompiler.cpp
227
@@ -539,17 +539,17 @@ CompileFunctionBody(JSContext *cx, Mutab
228
 
229
     MaybeCallSourceHandler(cx, options, srcBuf);
230
 
231
     if (!CheckLength(cx, srcBuf))
232
         return false;
233
 
234
     RootedScriptSource sourceObject(cx, CreateScriptSourceObject(cx, options));
235
     if (!sourceObject)
236
-        return nullptr;
237
+        return false;
238
     ScriptSource *ss = sourceObject->source();
239
 
240
     SourceCompressionTask sct(cx);
241
     JS_ASSERT(!options.sourceIsLazy);
242
     if (!cx->compartment()->options().discardSource()) {
243
         if (!ss->setSourceCopy(cx, srcBuf, true, &sct))
244
             return false;
245
     }

Return to bug 561960