Changeset 20107 in webkit
- Timestamp:
- Mar 11, 2007 8:24:45 PM (17 years ago)
- Location:
- trunk/WebKit
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebKit/ChangeLog
r20104 r20107 1 2007-03-11 Darin Adler <darin@apple.com> 2 3 Reviewed by Adele. 4 5 - fix http://bugs.webkit.org/show_bug.cgi?id=12964 6 <rdar://problem/5045717> REGRESSION: crash in -[WebBaseNetscapePluginStream _deliverData] 7 at simpsonsmovie.com (12964) 8 9 * Plugins/WebBaseNetscapePluginStream.m: 10 (-[WebBaseNetscapePluginStream startStreamResponseURL:expectedContentLength:lastModifiedDate:MIMEType:]): 11 At every place we call the plug-in, since it could destroy the stream, get pluginView into a local 12 variable; it will be set to nil if the stream is destroyed. 13 (-[WebBaseNetscapePluginStream _destroyStream]): Added calls to retain/release to handle the case where 14 one of the calls to the plug-in destroys the stream. Added a call to cancelPreviousPerformRequestsWithTarget 15 in case _deliverData has been scheduled but not yet delivered. Also get pluginView into a local variable 16 as mentioned above, and check at strategic points and exit if the stream was already destroyed to avoid 17 multiple calls to NPP_DestroyStream or NPP_URLNotify. 18 (-[WebBaseNetscapePluginStream _deliverData]): Ditto. 19 1 20 2007-03-10 Geoffrey Garen <ggaren@apple.com> 2 21 -
trunk/WebKit/Plugins/WebBaseNetscapePluginStream.m
r19747 r20107 1 1 /* 2 * Copyright (C) 2005 Apple Computer, Inc.All rights reserved.2 * Copyright (C) 2005, 2006, 2007 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 232 232 // FIXME: Need a way to check if stream is seekable 233 233 234 [pluginView willCallPlugInFunction]; 234 WebBaseNetscapePluginView *pv = pluginView; 235 [pv willCallPlugInFunction]; 235 236 NPError npErr = NPP_NewStream(plugin, (char *)[MIMEType UTF8String], &stream, NO, &transferMode); 236 [p luginViewdidCallPlugInFunction];237 [pv didCallPlugInFunction]; 237 238 LOG(Plugins, "NPP_NewStream URL=%@ MIME=%@ error=%d", responseURL, MIMEType, npErr); 238 239 … … 275 276 if (isTerminated) 276 277 return; 277 278 279 [self retain]; 280 278 281 ASSERT(reason != WEB_REASON_NONE); 279 282 ASSERT([deliveryData length] == 0); 280 283 281 if (stream.ndata != NULL) { 284 [NSObject cancelPreviousPerformRequestsWithTarget:self selector:@selector(_deliverData) object:nil]; 285 286 if (stream.ndata != nil) { 282 287 if (reason == NPRES_DONE && (transferMode == NP_ASFILE || transferMode == NP_ASFILEONLY)) { 283 288 ASSERT(path != NULL); 284 289 char *carbonPath = CarbonPathFromPOSIXPath(path); 285 290 ASSERT(carbonPath != NULL); 286 [pluginView willCallPlugInFunction]; 291 WebBaseNetscapePluginView *pv = pluginView; 292 [pv willCallPlugInFunction]; 287 293 NPP_StreamAsFile(plugin, &stream, carbonPath); 288 [p luginViewdidCallPlugInFunction];294 [pv didCallPlugInFunction]; 289 295 290 296 // Delete the file after calling NPP_StreamAsFile(), instead of in -dealloc/-finalize. It should be OK … … 297 303 LOG(Plugins, "NPP_StreamAsFile responseURL=%@ path=%s", responseURL, carbonPath); 298 304 free(carbonPath); 299 } 300 305 306 if (isTerminated) 307 goto exit; 308 } 309 301 310 NPError npErr; 302 [pluginView willCallPlugInFunction]; 311 WebBaseNetscapePluginView *pv = pluginView; 312 [pv willCallPlugInFunction]; 303 313 npErr = NPP_DestroyStream(plugin, &stream, reason); 304 [p luginViewdidCallPlugInFunction];314 [pv didCallPlugInFunction]; 305 315 LOG(Plugins, "NPP_DestroyStream responseURL=%@ error=%d", responseURL, npErr); 306 316 307 317 stream.ndata = nil; 308 } 309 318 319 if (isTerminated) 320 goto exit; 321 } 322 310 323 if (sendNotification) { 311 324 // NPP_URLNotify expects the request URL, not the response URL. 312 [pluginView willCallPlugInFunction]; 325 WebBaseNetscapePluginView *pv = pluginView; 326 [pv willCallPlugInFunction]; 313 327 NPP_URLNotify(plugin, [requestURL _web_URLCString], reason, notifyData); 314 [p luginViewdidCallPlugInFunction];328 [pv didCallPlugInFunction]; 315 329 LOG(Plugins, "NPP_URLNotify requestURL=%@ reason=%d", requestURL, reason); 316 330 } 317 331 318 332 isTerminated = YES; 319 333 320 334 [self setPlugin:NULL]; 335 336 exit: 337 [self release]; 321 338 } 322 339 … … 396 413 if (!stream.ndata || [deliveryData length] == 0) 397 414 return; 398 415 416 [self retain]; 417 399 418 int32 totalBytes = [deliveryData length]; 400 419 int32 totalBytesDelivered = 0; 401 420 402 421 while (totalBytesDelivered < totalBytes) { 403 [pluginView willCallPlugInFunction]; 422 WebBaseNetscapePluginView *pv = pluginView; 423 [pv willCallPlugInFunction]; 404 424 int32 deliveryBytes = NPP_WriteReady(plugin, &stream); 405 [p luginViewdidCallPlugInFunction];425 [pv didCallPlugInFunction]; 406 426 LOG(Plugins, "NPP_WriteReady responseURL=%@ bytes=%d", responseURL, deliveryBytes); 407 427 428 if (isTerminated) 429 goto exit; 430 408 431 if (deliveryBytes <= 0) { 409 432 // Plug-in can't receive anymore data right now. Send it later. … … 413 436 deliveryBytes = MIN(deliveryBytes, totalBytes - totalBytesDelivered); 414 437 NSData *subdata = [deliveryData subdataWithRange:NSMakeRange(totalBytesDelivered, deliveryBytes)]; 415 [pluginView willCallPlugInFunction]; 438 pv = pluginView; 439 [pv willCallPlugInFunction]; 416 440 deliveryBytes = NPP_Write(plugin, &stream, offset, [subdata length], (void *)[subdata bytes]); 417 [p luginViewdidCallPlugInFunction];441 [pv didCallPlugInFunction]; 418 442 if (deliveryBytes < 0) { 419 443 // Netscape documentation says that a negative result from NPP_Write means cancel the load. … … 427 451 } 428 452 } 429 453 430 454 if (totalBytesDelivered > 0) { 431 455 if (totalBytesDelivered < totalBytes) { … … 441 465 } 442 466 } 467 468 exit: 469 [self release]; 443 470 } 444 471
Note: See TracChangeset
for help on using the changeset viewer.