mirror of
https://gitlab.uni-freiburg.de/opensourcevdi/spice
synced 2026-01-07 11:55:10 +00:00
tests: Avoid malloc failures
test-display-streaming is calling malloc() without checking its return value. Coverity warns about this. This commit switches to g_malloc() to sidestep this warning (g_malloc() never returns NULL but aborts instead).
This commit is contained in:
parent
3ac428b4b7
commit
7d9018d441
@ -6,6 +6,7 @@ AM_CPPFLAGS = \
|
||||
-I$(top_srcdir)/server \
|
||||
-I$(top_srcdir)/server/tests \
|
||||
$(COMMON_CFLAGS) \
|
||||
$(GLIB2_CFLAGS) \
|
||||
$(SMARTCARD_CFLAGS) \
|
||||
$(SPICE_NONPKGCONFIG_CFLAGS) \
|
||||
$(NULL)
|
||||
@ -17,6 +18,7 @@ endif
|
||||
LDADD = \
|
||||
$(top_builddir)/spice-common/common/libspice-common.la \
|
||||
$(top_builddir)/server/libspice-server.la \
|
||||
$(GLIB2_LIBS) \
|
||||
$(NULL)
|
||||
|
||||
COMMON_BASE = \
|
||||
|
||||
@ -5,12 +5,16 @@
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <assert.h>
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
#include <time.h>
|
||||
|
||||
#include <glib.h>
|
||||
|
||||
#include "test_display_base.h"
|
||||
|
||||
static int sized;
|
||||
@ -29,7 +33,7 @@ static void create_overlay(Command *command , int width, int height)
|
||||
cmd->bbox.bottom = height;
|
||||
|
||||
cmd->num_clip_rects = 0;
|
||||
cmd->bitmap = malloc(width * height * 4 );
|
||||
cmd->bitmap = g_malloc(width * height * 4 );
|
||||
dst = (uint32_t *)cmd->bitmap;
|
||||
for (int i = 0; i < width * height; i++, dst++) {
|
||||
*dst = 0x8B008B;
|
||||
@ -100,7 +104,7 @@ static void create_clipped_frame(Test *test, Command *command, int clipping_fact
|
||||
end_line += 50;
|
||||
}
|
||||
|
||||
cmd->bitmap = malloc(width*height*4);
|
||||
cmd->bitmap = g_malloc(width*height*4);
|
||||
memset(cmd->bitmap, 0xff, width*height*4);
|
||||
dst = (uint32_t *)(cmd->bitmap + cur_line*width*4);
|
||||
for (cur_line; cur_line < end_line; cur_line++) {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user