return NULL;
h->scanner_config = NULL;
+ h->scan_status = NULL;
+ h->image = NULL;
+ h-> coord = NULL;
+
h->scan_status = malloc(sizeof(scan_status_t));
+ if (h->scan_status == NULL) {
+ kds_s2000w_handler_free(h);
+ return NULL;
+ }
+
h->image = malloc(sizeof(imagedata_t));
+ if (h->image == NULL) {
+ kds_s2000w_handler_free(h);
+ return NULL;
+ }
+ h->image->data = NULL;
+
h->coord = malloc(sizeof(coord_t));
+ if (h->coord == NULL) {
+ kds_s2000w_handler_free(h);
+ return NULL;
+ }
h->profile = 0;
h->sessionid = 0;
h->scan_status->downloaded_images = 0;
h->scan_status->read_bytes = 0;
h->image->size = 0;
- h->image->data = NULL;
h->coord->offset_x = 0;
h->coord->offset_y = 0;
h->coord->width = 0;
h->scanner_config = NULL;
free(h->scan_status);
h->scan_status = NULL;
- free(h->image->data);
- h->image->data = NULL;
+ if (h->image != NULL) {
+ free(h->image->data);
+ h->image->data = NULL;
+ }
free(h->image);
h->image = NULL;
free(h->coord);
assert_int_equal(status, SANE_STATUS_NO_MEM);
+ status = 0;
+ set_no_mem_counter(1);
+ status = sane_kds_s2000w_net_open("kds_s2000w_net", hlist);
+
+ assert_int_equal(status, SANE_STATUS_NO_MEM);
+
+ status = 0;
+ set_no_mem_counter(2);
+ status = sane_kds_s2000w_net_open("kds_s2000w_net", hlist);
+
+ assert_int_equal(status, SANE_STATUS_NO_MEM);
+
+ status = 0;
+ set_no_mem_counter(3);
+ status = sane_kds_s2000w_net_open("kds_s2000w_net", hlist);
+
+ assert_int_equal(status, SANE_STATUS_NO_MEM);
+
free(hlist);
hlist = NULL;
}