Пример #1
0
void *g_malloc0_n(size_t nmemb, size_t size)
{
    size_t sz;
    void *ptr;

    __coverity_negative_sink__(nmemb);
    __coverity_negative_sink__(size);
    sz = nmemb * size;
    ptr = __coverity_alloc__(sz);
    __coverity_writeall0__(ptr);
    __coverity_mark_as_afm_allocated__(ptr, "g_free");
    return ptr;
}
Пример #2
0
static void __read(uint8_t *buf, ssize_t len)
{
    __coverity_negative_sink__(len);
    if (len == 0) return;
    int first = buf[0];
    int last = buf[len-1];
}
Пример #3
0
void *isc__mem_allocate(void *mem, unsigned int size FLARG) {
	if (!mem) __coverity_panic__();
	__coverity_negative_sink__(size);
	if (condition)
		return (0);
	return (__coverity_alloc__(size));
}
Пример #4
0
void *g_realloc_n(void *ptr, size_t nmemb, size_t size)
{
    size_t sz;

    __coverity_negative_sink__(nmemb);
    __coverity_negative_sink__(size);
    sz = nmemb * size;
    __coverity_escape__(ptr);
    ptr = __coverity_alloc__(sz);
    /*
     * Memory beyond the old size isn't actually initialized.  Can't
     * model that.  See Coverity's realloc() model
     */
    __coverity_writeall__(ptr);
    __coverity_mark_as_afm_allocated__(ptr, "g_free");
    return ptr;
}
Пример #5
0
static void __write(uint8_t *buf, ssize_t len)
{
    int first, last;
    __coverity_negative_sink__(len);
    if (len == 0) return;
    buf[0] = first;
    buf[len-1] = last;
    __coverity_writeall__(buf);
}
Пример #6
0
void *av_mallocz(size_t size) {
    int has_memory;
    __coverity_negative_sink__(size);
    if (has_memory) {
        void *ptr = __coverity_alloc__(size);
        __coverity_writeall0__(ptr);
        __coverity_mark_as_afm_allocated__(ptr, "av_free");
        return ptr;
    } else {
        return 0;
    }
}
Пример #7
0
char *g_strndup(const char *s, size_t n)
{
    char *dup;
    size_t i;

    __coverity_negative_sink__(n);

    if (!s) {
        return NULL;
    }

    dup = g_malloc(n + 1);
    for (i = 0; i < n && (dup[i] = s[i]); i++) ;
    dup[i] = 0;
    return dup;
}