Chernov Dmitriy
2016-03-02 3344d1a728d37f0fb3e82a6a945eee0c780eb734
Fix potential memory leak. #73
1个文件已修改
9 ■■■■■ 已修改文件
libscpi/src/utils.c 9 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
libscpi/src/utils.c
@@ -768,11 +768,14 @@
        return NULL;
    }
    
    size_t len=strlen(s);
    if( ( len == 0 ) || ( len > heap->count ) ){
    if( *s == '\0' ){
        return NULL;
    }
    len++;    // additional '\0' at end
    size_t len=strlen(s) + 1;    // additional '\0' at end
    if( len > heap->count ) {
        return NULL;
    }
    char * ptrs = s;
    char * head = &heap->data[heap->wr];
    size_t rem = heap->size - (&heap->data[heap->wr]-heap->data);