Changeset 214924 in libssh2


Ignore:
Timestamp:
02/16/10 13:14:03 (2 years ago)
Author:
peter.stuge.se
Branches:
master
Children:
72ae08
Parents:
a49101
git-author:
Peter Stuge <peter@…> (02/16/10 13:14:03)
git-committer:
Peter Stuge <peter@…> (02/16/10 13:21:57)
Message:

Fix resource and memory leaks in examples as reported by cppcheck

Thanks to Ettl Martin for the report and patch. This fixes #132

Location:
example
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • example/scp_write.c

    r6df87e r214924  
    198198    close(sock); 
    199199#endif 
     200    if (local) 
     201        fclose(local); 
    200202    fprintf(stderr, "all done\n"); 
    201203    return 0; 
  • example/sftp_RW_nonblock.c

    r6df87e r214924  
    284284    close(sock); 
    285285#endif 
     286    if (tempstorage) 
     287        fclose(tempstorage); 
    286288    printf("all done\n"); 
    287289    return 0; 
  • example/sftp_write.c

    r6df87e r214924  
    185185    } while (1); 
    186186 
    187     fclose(local); 
    188187    libssh2_sftp_close(sftp_handle); 
    189188    libssh2_sftp_shutdown(sftp_session); 
    190189 
    191  shutdown: 
    192  
     190shutdown: 
    193191    libssh2_session_disconnect(session, 
    194192                               "Normal Shutdown, Thank you for playing"); 
     
    200198    close(sock); 
    201199#endif 
    202 printf("all done\n"); 
     200    if (local) 
     201        fclose(local); 
     202    printf("all done\n"); 
    203203    return 0; 
    204204} 
  • example/x11.c

    rb5e358 r214924  
    122122            ptr = strrchr(display, ':'); 
    123123            temp_buff = (char *) calloc(strlen(ptr+1), sizeof(char)); 
     124            if (!temp_buff) { 
     125                perror("calloc"); 
     126                return; 
     127            } 
    124128            memcpy(temp_buff, ptr+1, strlen(ptr+1)); 
    125129            display_port = atoi(temp_buff); 
    126  
    127             sock = socket(AF_UNIX,SOCK_STREAM, 0); 
    128             if (sock <0) 
     130            free(temp_buff); 
     131 
     132            sock = socket(AF_UNIX, SOCK_STREAM, 0); 
     133            if (sock < 0) 
    129134                return; 
    130135            memset(&addr, 0, sizeof(addr)); 
Note: See TracChangeset for help on using the changeset viewer.