[CONC-292] Erroneous malloc() result check in mariadb_dyncol_val_double() Created: 2017-11-07  Updated: 2018-01-13  Resolved: 2017-11-08

Status: Closed
Project: MariaDB Connector/C
Component/s: None
Affects Version/s: 3.0.2
Fix Version/s: 3.0.3

Type: Bug Priority: Major
Reporter: Karen Arutyunov Assignee: Georg Richter
Resolution: Fixed Votes: 0
Labels: None


 Description   

mariadb_dyncol_val_double() function (defined in libmariadb/mariadb_dyncol.c) has the following code:

  if ((str= malloc(val->x.string.value.length + 1)))
    return ER_DYNCOL_RESOURCE;
  memcpy(str, val->x.string.value.str, val->x.string.value.length);

Shouldn't it be

  if ((str= malloc(val->x.string.value.length + 1)) == NULL)
  ...

instead?



 Comments   
Comment by Georg Richter [ 2017-11-08 ]

commit 1e6cdb81cd7ce7e69db1daaeac9b6908105054e1
Author: Georg Richter <georg@mariadb.com>
Date: Wed Nov 8 04:56:04 2017 +0100

Generated at Thu Feb 08 03:04:16 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.