summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristophe Fergeau <cfergeau@redhat.com>2014-01-02 18:07:16 +0100
committerChristophe Fergeau <cfergeau@redhat.com>2014-01-02 18:07:16 +0100
commit7d9018d441cbb91207157b787c510da03101ef98 (patch)
treea69b2fafd107b21b29d403eaabd1203f044d01d6
parent3ac428b4b7f094ac091b2b8c39b47f90a74b9769 (diff)
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).
-rw-r--r--server/tests/Makefile.am2
-rw-r--r--server/tests/test_display_streaming.c8
2 files changed, 8 insertions, 2 deletions
diff --git a/server/tests/Makefile.am b/server/tests/Makefile.am
index f4ae661b..e2201ccc 100644
--- a/server/tests/Makefile.am
+++ b/server/tests/Makefile.am
@@ -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 = \
diff --git a/server/tests/test_display_streaming.c b/server/tests/test_display_streaming.c
index b66d8709..01c7e7ab 100644
--- a/server/tests/test_display_streaming.c
+++ b/server/tests/test_display_streaming.c
@@ -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++) {