@@ -122,16 +122,13 @@ void h_close_mariadb(struct _h_connection * conn) {
122122 */
123123char * h_escape_string_mariadb (const struct _h_connection * conn , const char * unsafe ) {
124124 char * escaped = o_malloc (2 * o_strlen (unsafe ) + 1 ), * to_return = NULL ;
125- unsigned long res ;
126-
127125 if (escaped == NULL ) {
128126 y_log_message (Y_LOG_LEVEL_ERROR , "Hoel - Error allocating memory for escaped" );
129127 return NULL ;
130128 }
131- res = mysql_real_escape_string (((struct _h_mariadb * )conn -> connection )-> db_handle , escaped , unsafe , o_strlen (unsafe ));
132- if (res && res != (unsigned long )-1 ) {
133- to_return = o_strndup (escaped , (size_t )res );
134- }
129+ escaped [0 ] = '\0' ;
130+ mysql_real_escape_string (((struct _h_mariadb * )conn -> connection )-> db_handle , escaped , unsafe , o_strlen (unsafe ));
131+ to_return = o_strdup (escaped );
135132 o_free (escaped );
136133 return to_return ;
137134}
@@ -141,12 +138,14 @@ char * h_escape_string_mariadb(const struct _h_connection * conn, const char * u
141138 * returned value must be free'd after use
142139 */
143140char * h_escape_string_with_quotes_mariadb (const struct _h_connection * conn , const char * unsafe ) {
144- char * escaped = h_escape_string_mariadb (conn , unsafe ), * to_return = NULL ;
145- if (escaped ! = NULL ) {
146- to_return = msprintf ( "'%s'" , escaped );
147- o_free ( escaped ) ;
141+ char * escaped = h_escape_string_mariadb (conn , unsafe ), * escaped_returned = NULL ;
142+ if (escaped = = NULL ) {
143+ y_log_message ( Y_LOG_LEVEL_ERROR , "Hoel - Error h_escape_string_mariadb" );
144+ return NULL ;
148145 }
149- return to_return ;
146+ escaped_returned = msprintf ("'%s'" , escaped );
147+ o_free (escaped );
148+ return escaped_returned ;
150149}
151150
152151/**
0 commit comments