cryptospore / rpms / qemu-kvm

Forked from rpms/qemu-kvm 2 years ago
Clone

Blame SOURCES/kvm-util-uri-realloc2n-can-t-fail-drop-dead-error-handli.patch

05bba0
From 3704c5a2d54b2e4e492ce7dc8606fe1dc4a2c547 Mon Sep 17 00:00:00 2001
05bba0
From: Markus Armbruster <armbru@redhat.com>
05bba0
Date: Tue, 8 Sep 2015 18:06:23 +0200
05bba0
Subject: [PATCH 5/7] util/uri: realloc2n() can't fail, drop dead error
05bba0
 handling
05bba0
05bba0
Message-id: <1441735585-23432-6-git-send-email-armbru@redhat.com>
05bba0
Patchwork-id: 67710
05bba0
O-Subject: [RHEL-7.2 qemu-kvm PATCH 5/7] util/uri: realloc2n() can't fail, drop dead error handling
05bba0
Bugzilla: 1218919
05bba0
RH-Acked-by: Laszlo Ersek <lersek@redhat.com>
05bba0
RH-Acked-by: Fam Zheng <famz@redhat.com>
05bba0
RH-Acked-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
05bba0
05bba0
Signed-off-by: Markus Armbruster <armbru@redhat.com>
05bba0
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
05bba0
(cherry picked from commit afd5ea3671f936f511015a71af9cd0ed23788515)
05bba0
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
05bba0
---
05bba0
 util/uri.c | 22 ----------------------
05bba0
 1 file changed, 22 deletions(-)
05bba0
05bba0
diff --git a/util/uri.c b/util/uri.c
05bba0
index aa39694..b9a7b54 100644
05bba0
--- a/util/uri.c
05bba0
+++ b/util/uri.c
05bba0
@@ -1049,14 +1049,12 @@ uri_to_string(URI *uri) {
05bba0
 	while (*p != 0) {
05bba0
 	    if (len >= max) {
05bba0
                 temp = realloc2n(ret, &max;;
05bba0
-                if (temp == NULL) goto mem_error;
05bba0
 		ret = temp;
05bba0
 	    }
05bba0
 	    ret[len++] = *p++;
05bba0
 	}
05bba0
 	if (len >= max) {
05bba0
             temp = realloc2n(ret, &max;;
05bba0
-            if (temp == NULL) goto mem_error;
05bba0
             ret = temp;
05bba0
 	}
05bba0
 	ret[len++] = ':';
05bba0
@@ -1066,7 +1064,6 @@ uri_to_string(URI *uri) {
05bba0
 	while (*p != 0) {
05bba0
 	    if (len + 3 >= max) {
05bba0
                 temp = realloc2n(ret, &max;;
05bba0
-                if (temp == NULL) goto mem_error;
05bba0
                 ret = temp;
05bba0
 	    }
05bba0
 	    if (IS_RESERVED(*(p)) || IS_UNRESERVED(*(p)))
05bba0
@@ -1083,7 +1080,6 @@ uri_to_string(URI *uri) {
05bba0
 	if (uri->server != NULL) {
05bba0
 	    if (len + 3 >= max) {
05bba0
                 temp = realloc2n(ret, &max;;
05bba0
-                if (temp == NULL) goto mem_error;
05bba0
                 ret = temp;
05bba0
 	    }
05bba0
 	    ret[len++] = '/';
05bba0
@@ -1093,7 +1089,6 @@ uri_to_string(URI *uri) {
05bba0
 		while (*p != 0) {
05bba0
 		    if (len + 3 >= max) {
05bba0
                         temp = realloc2n(ret, &max;;
05bba0
-                        if (temp == NULL) goto mem_error;
05bba0
                         ret = temp;
05bba0
 		    }
05bba0
 		    if ((IS_UNRESERVED(*(p))) ||
05bba0
@@ -1112,7 +1107,6 @@ uri_to_string(URI *uri) {
05bba0
 		}
05bba0
 		if (len + 3 >= max) {
05bba0
                     temp = realloc2n(ret, &max;;
05bba0
-                    if (temp == NULL) goto mem_error;
05bba0
                     ret = temp;
05bba0
 		}
05bba0
 		ret[len++] = '@';
05bba0
@@ -1121,7 +1115,6 @@ uri_to_string(URI *uri) {
05bba0
 	    while (*p != 0) {
05bba0
 		if (len >= max) {
05bba0
                     temp = realloc2n(ret, &max;;
05bba0
-                    if (temp == NULL) goto mem_error;
05bba0
                     ret = temp;
05bba0
 		}
05bba0
 		ret[len++] = *p++;
05bba0
@@ -1129,7 +1122,6 @@ uri_to_string(URI *uri) {
05bba0
 	    if (uri->port > 0) {
05bba0
 		if (len + 10 >= max) {
05bba0
                     temp = realloc2n(ret, &max;;
05bba0
-                    if (temp == NULL) goto mem_error;
05bba0
                     ret = temp;
05bba0
 		}
05bba0
 		len += snprintf(&ret[len], max - len, ":%d", uri->port);
05bba0
@@ -1137,7 +1129,6 @@ uri_to_string(URI *uri) {
05bba0
 	} else if (uri->authority != NULL) {
05bba0
 	    if (len + 3 >= max) {
05bba0
                 temp = realloc2n(ret, &max;;
05bba0
-                if (temp == NULL) goto mem_error;
05bba0
                 ret = temp;
05bba0
 	    }
05bba0
 	    ret[len++] = '/';
05bba0
@@ -1146,7 +1137,6 @@ uri_to_string(URI *uri) {
05bba0
 	    while (*p != 0) {
05bba0
 		if (len + 3 >= max) {
05bba0
                     temp = realloc2n(ret, &max;;
05bba0
-                    if (temp == NULL) goto mem_error;
05bba0
                     ret = temp;
05bba0
 		}
05bba0
 		if ((IS_UNRESERVED(*(p))) ||
05bba0
@@ -1165,7 +1155,6 @@ uri_to_string(URI *uri) {
05bba0
 	} else if (uri->scheme != NULL) {
05bba0
 	    if (len + 3 >= max) {
05bba0
                 temp = realloc2n(ret, &max;;
05bba0
-                if (temp == NULL) goto mem_error;
05bba0
                 ret = temp;
05bba0
 	    }
05bba0
 	    ret[len++] = '/';
05bba0
@@ -1185,7 +1174,6 @@ uri_to_string(URI *uri) {
05bba0
 	        (!strcmp(uri->scheme, "file"))) {
05bba0
 		if (len + 3 >= max) {
05bba0
                     temp = realloc2n(ret, &max;;
05bba0
-                    if (temp == NULL) goto mem_error;
05bba0
                     ret = temp;
05bba0
 		}
05bba0
 		ret[len++] = *p++;
05bba0
@@ -1195,7 +1183,6 @@ uri_to_string(URI *uri) {
05bba0
 	    while (*p != 0) {
05bba0
 		if (len + 3 >= max) {
05bba0
                     temp = realloc2n(ret, &max;;
05bba0
-                    if (temp == NULL) goto mem_error;
05bba0
                     ret = temp;
05bba0
 		}
05bba0
 		if ((IS_UNRESERVED(*(p))) || ((*(p) == '/')) ||
05bba0
@@ -1215,7 +1202,6 @@ uri_to_string(URI *uri) {
05bba0
 	if (uri->query != NULL) {
05bba0
 	    if (len + 1 >= max) {
05bba0
                 temp = realloc2n(ret, &max;;
05bba0
-                if (temp == NULL) goto mem_error;
05bba0
                 ret = temp;
05bba0
 	    }
05bba0
 	    ret[len++] = '?';
05bba0
@@ -1223,7 +1209,6 @@ uri_to_string(URI *uri) {
05bba0
 	    while (*p != 0) {
05bba0
 		if (len + 1 >= max) {
05bba0
                     temp = realloc2n(ret, &max;;
05bba0
-                    if (temp == NULL) goto mem_error;
05bba0
                     ret = temp;
05bba0
 		}
05bba0
 		ret[len++] = *p++;
05bba0
@@ -1233,7 +1218,6 @@ uri_to_string(URI *uri) {
05bba0
     if (uri->fragment != NULL) {
05bba0
 	if (len + 3 >= max) {
05bba0
             temp = realloc2n(ret, &max;;
05bba0
-            if (temp == NULL) goto mem_error;
05bba0
             ret = temp;
05bba0
 	}
05bba0
 	ret[len++] = '#';
05bba0
@@ -1241,7 +1225,6 @@ uri_to_string(URI *uri) {
05bba0
 	while (*p != 0) {
05bba0
 	    if (len + 3 >= max) {
05bba0
                 temp = realloc2n(ret, &max;;
05bba0
-                if (temp == NULL) goto mem_error;
05bba0
                 ret = temp;
05bba0
 	    }
05bba0
 	    if ((IS_UNRESERVED(*(p))) || (IS_RESERVED(*(p))))
05bba0
@@ -1257,15 +1240,10 @@ uri_to_string(URI *uri) {
05bba0
     }
05bba0
     if (len >= max) {
05bba0
         temp = realloc2n(ret, &max;;
05bba0
-        if (temp == NULL) goto mem_error;
05bba0
         ret = temp;
05bba0
     }
05bba0
     ret[len] = 0;
05bba0
     return(ret);
05bba0
-
05bba0
-mem_error:
05bba0
-    g_free(ret);
05bba0
-    return(NULL);
05bba0
 }
05bba0
 
05bba0
 /**
05bba0
-- 
05bba0
1.8.3.1
05bba0