Changeset 20107 in webkit


Ignore:
Timestamp:
Mar 11, 2007 8:24:45 PM (17 years ago)
Author:
darin
Message:

Reviewed by Adele.

  • Plugins/WebBaseNetscapePluginStream.m: (-[WebBaseNetscapePluginStream startStreamResponseURL:expectedContentLength:lastModifiedDate:MIMEType:]): At every place we call the plug-in, since it could destroy the stream, get pluginView into a local variable; it will be set to nil if the stream is destroyed. (-[WebBaseNetscapePluginStream _destroyStream]): Added calls to retain/release to handle the case where one of the calls to the plug-in destroys the stream. Added a call to cancelPreviousPerformRequestsWithTarget in case _deliverData has been scheduled but not yet delivered. Also get pluginView into a local variable as mentioned above, and check at strategic points and exit if the stream was already destroyed to avoid multiple calls to NPP_DestroyStream or NPP_URLNotify. (-[WebBaseNetscapePluginStream _deliverData]): Ditto.
Location:
trunk/WebKit
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebKit/ChangeLog

    r20104 r20107  
     12007-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
    1202007-03-10  Geoffrey Garen  <ggaren@apple.com>
    221
  • trunk/WebKit/Plugins/WebBaseNetscapePluginStream.m

    r19747 r20107  
    11/*
    2  * Copyright (C) 2005 Apple Computer, Inc. All rights reserved.
     2 * Copyright (C) 2005, 2006, 2007 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    232232    // FIXME: Need a way to check if stream is seekable
    233233
    234     [pluginView willCallPlugInFunction];
     234    WebBaseNetscapePluginView *pv = pluginView;
     235    [pv willCallPlugInFunction];
    235236    NPError npErr = NPP_NewStream(plugin, (char *)[MIMEType UTF8String], &stream, NO, &transferMode);
    236     [pluginView didCallPlugInFunction];
     237    [pv didCallPlugInFunction];
    237238    LOG(Plugins, "NPP_NewStream URL=%@ MIME=%@ error=%d", responseURL, MIMEType, npErr);
    238239
     
    275276    if (isTerminated)
    276277        return;
    277    
     278
     279    [self retain];
     280
    278281    ASSERT(reason != WEB_REASON_NONE);
    279282    ASSERT([deliveryData length] == 0);
    280283   
    281     if (stream.ndata != NULL) {
     284    [NSObject cancelPreviousPerformRequestsWithTarget:self selector:@selector(_deliverData) object:nil];
     285
     286    if (stream.ndata != nil) {
    282287        if (reason == NPRES_DONE && (transferMode == NP_ASFILE || transferMode == NP_ASFILEONLY)) {
    283288            ASSERT(path != NULL);
    284289            char *carbonPath = CarbonPathFromPOSIXPath(path);
    285290            ASSERT(carbonPath != NULL);
    286             [pluginView willCallPlugInFunction];
     291            WebBaseNetscapePluginView *pv = pluginView;
     292            [pv willCallPlugInFunction];
    287293            NPP_StreamAsFile(plugin, &stream, carbonPath);
    288             [pluginView didCallPlugInFunction];
     294            [pv didCallPlugInFunction];
    289295
    290296            // Delete the file after calling NPP_StreamAsFile(), instead of in -dealloc/-finalize.  It should be OK
     
    297303            LOG(Plugins, "NPP_StreamAsFile responseURL=%@ path=%s", responseURL, carbonPath);
    298304            free(carbonPath);
    299         }
    300        
     305
     306            if (isTerminated)
     307                goto exit;
     308        }
     309
    301310        NPError npErr;
    302         [pluginView willCallPlugInFunction];
     311        WebBaseNetscapePluginView *pv = pluginView;
     312        [pv willCallPlugInFunction];
    303313        npErr = NPP_DestroyStream(plugin, &stream, reason);
    304         [pluginView didCallPlugInFunction];
     314        [pv didCallPlugInFunction];
    305315        LOG(Plugins, "NPP_DestroyStream responseURL=%@ error=%d", responseURL, npErr);
    306        
     316
    307317        stream.ndata = nil;
    308     }
    309    
     318
     319        if (isTerminated)
     320            goto exit;
     321    }
     322
    310323    if (sendNotification) {
    311324        // NPP_URLNotify expects the request URL, not the response URL.
    312         [pluginView willCallPlugInFunction];
     325        WebBaseNetscapePluginView *pv = pluginView;
     326        [pv willCallPlugInFunction];
    313327        NPP_URLNotify(plugin, [requestURL _web_URLCString], reason, notifyData);
    314         [pluginView didCallPlugInFunction];
     328        [pv didCallPlugInFunction];
    315329        LOG(Plugins, "NPP_URLNotify requestURL=%@ reason=%d", requestURL, reason);
    316330    }
    317    
     331
    318332    isTerminated = YES;
    319333
    320334    [self setPlugin:NULL];
     335
     336exit:
     337    [self release];
    321338}
    322339
     
    396413    if (!stream.ndata || [deliveryData length] == 0)
    397414        return;
    398    
     415
     416    [self retain];
     417
    399418    int32 totalBytes = [deliveryData length];
    400419    int32 totalBytesDelivered = 0;
    401    
     420
    402421    while (totalBytesDelivered < totalBytes) {
    403         [pluginView willCallPlugInFunction];
     422        WebBaseNetscapePluginView *pv = pluginView;
     423        [pv willCallPlugInFunction];
    404424        int32 deliveryBytes = NPP_WriteReady(plugin, &stream);
    405         [pluginView didCallPlugInFunction];
     425        [pv didCallPlugInFunction];
    406426        LOG(Plugins, "NPP_WriteReady responseURL=%@ bytes=%d", responseURL, deliveryBytes);
    407        
     427
     428        if (isTerminated)
     429            goto exit;
     430
    408431        if (deliveryBytes <= 0) {
    409432            // Plug-in can't receive anymore data right now. Send it later.
     
    413436            deliveryBytes = MIN(deliveryBytes, totalBytes - totalBytesDelivered);
    414437            NSData *subdata = [deliveryData subdataWithRange:NSMakeRange(totalBytesDelivered, deliveryBytes)];
    415             [pluginView willCallPlugInFunction];
     438            pv = pluginView;
     439            [pv willCallPlugInFunction];
    416440            deliveryBytes = NPP_Write(plugin, &stream, offset, [subdata length], (void *)[subdata bytes]);
    417             [pluginView didCallPlugInFunction];
     441            [pv didCallPlugInFunction];
    418442            if (deliveryBytes < 0) {
    419443                // Netscape documentation says that a negative result from NPP_Write means cancel the load.
     
    427451        }
    428452    }
    429    
     453
    430454    if (totalBytesDelivered > 0) {
    431455        if (totalBytesDelivered < totalBytes) {
     
    441465        }
    442466    }
     467
     468exit:
     469    [self release];
    443470}
    444471
Note: See TracChangeset for help on using the changeset viewer.